Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

修复部分设备编辑界面顶栏按钮重叠 #682

Merged
merged 1 commit into from
Oct 4, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions app/src/main/java/org/autojs/autojs/ui/edit/EditActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down
37 changes: 10 additions & 27 deletions app/src/main/java/org/autojs/autojs/ui/edit/EditorView.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -152,7 +142,6 @@ public void onReceive(Context context, Intent intent) {
}
}
};

private SparseBooleanArray mMenuItemStatus = new SparseBooleanArray();
private String mRestoredText;
private NormalToolbarFragment mNormalToolbar = new NormalToolbarFragment_();
Expand Down Expand Up @@ -240,7 +229,6 @@ private Observable<String> handleText(Intent intent) {
}
}


@SuppressLint("CheckResult")
private Observable<String> loadUri(final Uri uri) {
mEditor.setProgress(true);
Expand All @@ -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()
Expand Down Expand Up @@ -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());
Expand Down Expand Up @@ -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();
}

Expand All @@ -455,7 +440,6 @@ public ScriptExecution run(boolean showMessage) {
return execution;
}


public void undo() {
mEditor.undo();
}
Expand Down Expand Up @@ -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();
Expand All @@ -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();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,6 @@ public class NormalToolbarFragment extends ToolbarFragment {

@Override
public List<Integer> 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);
}
}
26 changes: 18 additions & 8 deletions app/src/main/res/layout/fragment_normal_toolbar.xml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

<org.autojs.autojs.ui.widget.ToolbarMenuItem
android:id="@+id/edit"
android:layout_width="37dp"
android:layout_width="38dp"
android:layout_height="match_parent"
app:icon="@drawable/ic_edit_black_48dp"
app:icon_color="@color/toolbar"
Expand All @@ -19,7 +19,7 @@

<org.autojs.autojs.ui.widget.ToolbarMenuItem
android:id="@+id/jump"
android:layout_width="37dp"
android:layout_width="38dp"
android:layout_height="match_parent"
app:icon="@drawable/ic_low_priority_black_48dp"
app:icon_color="@color/toolbar"
Expand All @@ -29,17 +29,27 @@

<org.autojs.autojs.ui.widget.ToolbarMenuItem
android:id="@+id/debug"
android:layout_width="37dp"
android:layout_width="38dp"
android:layout_height="match_parent"
app:icon="@drawable/ic_bug_report_black_48dp"
app:icon_color="@color/toolbar"
app:layout_constraintStart_toEndOf="@id/jump"
app:layout_constraintTop_toTopOf="parent"
app:text="@string/text_debug" />

<org.autojs.autojs.ui.widget.ToolbarMenuItem
android:id="@+id/others"
android:layout_width="38dp"
android:layout_height="match_parent"
app:icon="@drawable/ic_more_horiz_black_48dp"
app:icon_color="@color/toolbar"
app:layout_constraintStart_toEndOf="@id/debug"
app:layout_constraintTop_toTopOf="parent"
app:text="@string/text_others" />

<org.autojs.autojs.ui.widget.ToolbarMenuItem
android:id="@id/action_log"
android:layout_width="37dp"
android:layout_width="38dp"
android:layout_height="match_parent"
app:icon="@drawable/ic_ali_log"
app:icon_color="@color/toolbar"
Expand All @@ -49,7 +59,7 @@

<org.autojs.autojs.ui.widget.ToolbarMenuItem
android:id="@+id/run"
android:layout_width="37dp"
android:layout_width="38dp"
android:layout_height="match_parent"
app:icon="@drawable/ic_play_arrow_black_48dp"
app:icon_color="@color/toolbar"
Expand All @@ -59,7 +69,7 @@

<org.autojs.autojs.ui.widget.ToolbarMenuItem
android:id="@+id/undo"
android:layout_width="37dp"
android:layout_width="38dp"
android:layout_height="match_parent"
app:icon="@drawable/ic_undo_black_48dp"
app:icon_color="@color/toolbar"
Expand All @@ -69,7 +79,7 @@

<org.autojs.autojs.ui.widget.ToolbarMenuItem
android:id="@+id/redo"
android:layout_width="37dp"
android:layout_width="38dp"
android:layout_height="match_parent"
app:icon="@drawable/ic_redo_black_48dp"
app:icon_color="@color/toolbar"
Expand All @@ -79,7 +89,7 @@

<org.autojs.autojs.ui.widget.ToolbarMenuItem
android:id="@+id/save"
android:layout_width="37dp"
android:layout_width="38dp"
android:layout_height="match_parent"
android:enabled="false"
android:gravity="center"
Expand Down
Loading