diff --git a/app/src/main/java/org/autojs/autojs/ui/edit/EditActivity.java b/app/src/main/java/org/autojs/autojs/ui/edit/EditActivity.java index 8a8b2ec19..3252abe77 100644 --- a/app/src/main/java/org/autojs/autojs/ui/edit/EditActivity.java +++ b/app/src/main/java/org/autojs/autojs/ui/edit/EditActivity.java @@ -130,14 +130,14 @@ private void onLoadFileError(String message) { } private void setUpToolbar() { - BaseActivity.setToolbarAsBack(this, R.id.toolbar, "" ); +// BaseActivity.setToolbarAsBack(this, R.id.toolbar, "" ); TextView filePath= findViewById(R.id.file_path); filePath.setText(mEditorView.getUri().getPath()); } @Override public boolean onCreateOptionsMenu(Menu menu) { - getMenuInflater().inflate(R.menu.menu_editor, menu); +// getMenuInflater().inflate(R.menu.menu_editor, menu); return true; } diff --git a/app/src/main/java/org/autojs/autojs/ui/edit/EditorView.java b/app/src/main/java/org/autojs/autojs/ui/edit/EditorView.java index 309dce496..0cb5b5857 100644 --- a/app/src/main/java/org/autojs/autojs/ui/edit/EditorView.java +++ b/app/src/main/java/org/autojs/autojs/ui/edit/EditorView.java @@ -96,34 +96,24 @@ public class EditorView extends FrameLayout implements CodeCompletionBar.OnHintC public static final String EXTRA_READ_ONLY = "readOnly"; public static final String EXTRA_SAVE_ENABLED = "saveEnabled"; public static final String EXTRA_RUN_ENABLED = "runEnabled"; - @ViewById(R.id.editor) CodeEditor mEditor; - @ViewById(R.id.code_completion_bar) CodeCompletionBar mCodeCompletionBar; - @ViewById(R.id.input_method_enhance_bar) View mInputMethodEnhanceBar; - @ViewById(R.id.symbol_bar) CodeCompletionBar mSymbolBar; - @ViewById(R.id.functions) ImageView mShowFunctionsButton; - @ViewById(R.id.functions_keyboard) FunctionsKeyboardView mFunctionsKeyboard; - @ViewById(R.id.debug_bar) DebugBar mDebugBar; - @ViewById(R.id.docs) EWebView mDocsWebView; - @ViewById(R.id.drawer_layout) DrawerLayout mDrawerLayout; - private String mName; private Uri mUri; private boolean mReadOnly = false; @@ -152,7 +142,6 @@ public void onReceive(Context context, Intent intent) { } } }; - private SparseBooleanArray mMenuItemStatus = new SparseBooleanArray(); private String mRestoredText; private NormalToolbarFragment mNormalToolbar = new NormalToolbarFragment_(); @@ -240,7 +229,6 @@ private Observable handleText(Intent intent) { } } - @SuppressLint("CheckResult") private Observable loadUri(final Uri uri) { mEditor.setProgress(true); @@ -262,7 +250,6 @@ private void setInitialText(String text) { mEditor.setInitialText(text); } - private void setMenuItemStatus(int id, boolean enabled) { mMenuItemStatus.put(id, enabled); ToolbarFragment fragment = (ToolbarFragment) getActivity().getSupportFragmentManager() @@ -331,7 +318,6 @@ private void setUpInputMethodEnhancedBar() { mAutoCompletion.setAutoCompleteCallback(mCodeCompletionBar::setCodeCompletions); } - private void setUpEditor() { mEditor.getCodeEditText().addTextChangedListener(new SimpleTextWatcher(s -> { setMenuItemStatus(R.id.save, mEditor.isTextChanged()); @@ -413,25 +399,24 @@ public void onToolbarMenuItemClick(View view) { LogActivityKt.start(getContext()); break; case R.id.debug: - showOptionMenu(view,R.menu.menu_editor_debug); + showOptionMenu(view, R.menu.menu_editor_debug); break; case R.id.jump: - showOptionMenu(view,R.menu.menu_editor_jump); + showOptionMenu(view, R.menu.menu_editor_jump); break; case R.id.edit: - showOptionMenu(view,R.menu.menu_editor_edit); + showOptionMenu(view, R.menu.menu_editor_edit); + break; + case R.id.others: + showOptionMenu(view, R.menu.menu_editor); break; } } - void showOptionMenu( View view,int menuId) { + + void showOptionMenu(View view, int menuId) { PopupMenu popupMenu = new PopupMenu(getContext(), view); popupMenu.inflate(menuId); - popupMenu.setOnMenuItemClickListener(new PopupMenu.OnMenuItemClickListener() { - @Override - public boolean onMenuItemClick(MenuItem item) { - return mEditorMenu.onOptionsItemSelected(item); - } - }); + popupMenu.setOnMenuItemClickListener(mEditorMenu::onOptionsItemSelected); popupMenu.show(); } @@ -455,7 +440,6 @@ public ScriptExecution run(boolean showMessage) { return execution; } - public void undo() { mEditor.undo(); } @@ -634,7 +618,6 @@ public void replaceAll(String keywords, String replacement, boolean usingRegex) mEditor.replaceAll(keywords, replacement, usingRegex); } - public void debug() { DebugToolbarFragment debugToolbarFragment = DebugToolbarFragment_.builder() .build(); @@ -661,7 +644,7 @@ public void exitDebugging() { private void showErrorMessage(String msg) { Snackbar.make(EditorView.this, getResources().getString(R.string.text_error) + ": " + msg, Snackbar.LENGTH_LONG) - .setAction(R.string.text_detail, v -> LogActivityKt.start(getContext()) ) + .setAction(R.string.text_detail, v -> LogActivityKt.start(getContext())) .show(); } diff --git a/app/src/main/java/org/autojs/autojs/ui/edit/toolbar/NormalToolbarFragment.java b/app/src/main/java/org/autojs/autojs/ui/edit/toolbar/NormalToolbarFragment.java index fc56a0d75..c6bcb03b6 100644 --- a/app/src/main/java/org/autojs/autojs/ui/edit/toolbar/NormalToolbarFragment.java +++ b/app/src/main/java/org/autojs/autojs/ui/edit/toolbar/NormalToolbarFragment.java @@ -11,6 +11,6 @@ public class NormalToolbarFragment extends ToolbarFragment { @Override public List getMenuItemIds() { - return Arrays.asList(R.id.edit, R.id.jump, R.id.debug, R.id.action_log, R.id.run, R.id.undo, R.id.redo, R.id.save); + return Arrays.asList(R.id.edit, R.id.jump, R.id.debug, R.id.others, R.id.action_log, R.id.run, R.id.undo, R.id.redo, R.id.save); } } diff --git a/app/src/main/res/layout/fragment_normal_toolbar.xml b/app/src/main/res/layout/fragment_normal_toolbar.xml index efe31081f..227593347 100644 --- a/app/src/main/res/layout/fragment_normal_toolbar.xml +++ b/app/src/main/res/layout/fragment_normal_toolbar.xml @@ -9,7 +9,7 @@ + +