From 59bb63b78d0e070d87e5854423b875089d663341 Mon Sep 17 00:00:00 2001 From: xiaomaomi <134966259+xiao-maomi@users.noreply.github.com> Date: Sun, 1 Oct 2023 14:31:32 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E9=83=A8=E5=88=86=E8=AE=BE?= =?UTF-8?q?=E5=A4=87=E7=BC=96=E8=BE=91=E7=95=8C=E9=9D=A2=E9=A1=B6=E6=A0=8F?= =?UTF-8?q?=E6=8C=89=E9=92=AE=E9=87=8D=E5=8F=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../autojs/autojs/ui/edit/EditActivity.java | 4 +- .../org/autojs/autojs/ui/edit/EditorView.java | 37 +++++-------------- .../edit/toolbar/NormalToolbarFragment.java | 2 +- .../res/layout/fragment_normal_toolbar.xml | 26 +++++++++---- 4 files changed, 31 insertions(+), 38 deletions(-) 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 @@ + +