Skip to content

Commit 5195e2e

Browse files
author
duy
committed
Fix soft keyboard not show after clicking "Clear input" item
1 parent fd4829d commit 5195e2e

7 files changed

+34
-32
lines changed

modules/programming/src/main/java/com/symja/programming/BaseProgrammingFragment.java

+16-14
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ private void setupViews(@NonNull View view) {
124124
private void addViewEvents(@NotNull View view) {
125125
btnRun.setOnClickListener(v -> clickRun());
126126

127-
View btnCopy = view.findViewById(R.id.btn_copy);
127+
View btnCopy = view.findViewById(R.id.symja_prgm_btn_copy);
128128
btnCopy.setOnClickListener(v -> {
129129
final Context context = getContext();
130130
String content = inputView.getText().toString();
@@ -133,7 +133,7 @@ private void addViewEvents(@NotNull View view) {
133133
ViewUtils.showToast(context, R.string.symja_prgm_message_copied, ViewUtils.LENGTH_SHORT);
134134
}
135135
});
136-
view.findViewById(R.id.btn_paste).setOnClickListener(v -> {
136+
view.findViewById(R.id.symja_prgm_btn_paste).setOnClickListener(v -> {
137137
final Context context = getContext();
138138
CharSequence clipboard = ClipboardCompat.getClipboard(context);
139139
if (clipboard != null) {
@@ -144,13 +144,13 @@ private void addViewEvents(@NotNull View view) {
144144
ViewUtils.showKeyboard(context, inputView);
145145
}
146146
});
147-
View btnUndo = view.findViewById(R.id.btn_undo);
147+
View btnUndo = view.findViewById(R.id.symja_prgm_btn_undo);
148148
btnUndo.setOnClickListener(v -> {
149149
if (inputView.canUndo()) {
150150
inputView.undo();
151151
}
152152
});
153-
View btnRedo = view.findViewById(R.id.btn_redo);
153+
View btnRedo = view.findViewById(R.id.symja_prgm_btn_redo);
154154
btnRedo.setOnClickListener(v -> {
155155
if (inputView.canRedo()) {
156156
inputView.redo();
@@ -369,9 +369,9 @@ public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceStat
369369
}
370370
});
371371

372-
txtErrorLabel = view.findViewById(R.id.txt_error_message);
373-
errorContainer = view.findViewById(R.id.error_container);
374-
btnCloseError = view.findViewById(R.id.btn_close_error_message);
372+
txtErrorLabel = view.findViewById(R.id.symja_prgm_txt_error_message);
373+
errorContainer = view.findViewById(R.id.symja_prgm_error_container);
374+
btnCloseError = view.findViewById(R.id.symja_prgm_btn_close_error_message);
375375
errorContainer.setVisibility(View.GONE);
376376
btnCloseError.setOnClickListener(v -> errorContainer.setVisibility(View.GONE));
377377

@@ -383,15 +383,15 @@ public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceStat
383383
listResultView.setAdapter(adapter);
384384
listResultView.setHasFixedSize(true);
385385

386-
btnRun = view.findViewById(R.id.btn_run);
386+
btnRun = view.findViewById(R.id.symja_prgm_btn_run);
387387
progressBar = view.findViewById(R.id.progress_bar);
388388
progressBar.setVisibility(View.GONE);
389389

390390
setupViews(view);
391391
addViewEvents(view);
392392
setupSymbolViews(view.findViewById(R.id.container_symbol), view);
393393

394-
ImageView resizeInputButton = view.findViewById(R.id.btn_resize_input);
394+
ImageView resizeInputButton = view.findViewById(R.id.symja_prgm_btn_resize_input);
395395
resizeInputButton.setOnClickListener(v -> inputExpanded.postValue(Boolean.FALSE.equals(inputExpanded.getValue())));
396396

397397
inputExpanded.observe(this.getViewLifecycleOwner(), expanded -> {
@@ -420,7 +420,7 @@ public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceStat
420420
inputExpanded.postValue(PreferenceManager.getDefaultSharedPreferences(requireContext())
421421
.getBoolean(this.getTag() + ".inputExpanded", true));
422422

423-
view.findViewById(R.id.btn_open_menu).setOnClickListener(this::openMenu);
423+
view.findViewById(R.id.symja_prgm_btn_open_menu).setOnClickListener(this::openMenu);
424424
}
425425

426426
private void openMenu(View v) {
@@ -431,17 +431,19 @@ private void openMenu(View v) {
431431
popupMenu.inflate(R.menu.symja_prgm_menu_programming_console, v);
432432
popupMenu.setOnMenuItemClickListener(item -> {
433433
int itemId = item.getItemId();
434-
if (itemId == R.id.action_clear_all_items) {
434+
if (itemId == R.id.symja_prgm_action_clear_all_items) {
435435
clickClearAll();
436436
return true;
437437
}
438-
if (itemId == R.id.action_clear_input) {
438+
if (itemId == R.id.symja_prgm_action_clear_input) {
439439
final Context context = requireContext();
440440
inputView.setText("");
441441
inputView.requestFocus();
442-
ViewUtils.showKeyboard(context, inputView);
442+
inputView.postDelayed(() -> {
443+
ViewUtils.showKeyboard(context, inputView);
444+
}, 500);
443445
return true;
444-
} else if (itemId == R.id.action_import_text_file) {
446+
} else if (itemId == R.id.symja_prgm_action_import_text_file) {
445447
importTextFile();
446448
return true;
447449
}

modules/programming/src/main/java/com/symja/programming/console/viewholder/BaseViewHolder.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ public abstract class BaseViewHolder extends RecyclerView.ViewHolder {
4646
super(itemView);
4747
txtTitle = itemView.findViewById(R.id.txt_title);
4848

49-
txtErrorMessage = itemView.findViewById(R.id.txt_error_message);
49+
txtErrorMessage = itemView.findViewById(R.id.symja_prgm_txt_error_message);
5050
txtStandardMessage = itemView.findViewById(R.id.txt_standard_message);
5151
containerMessage = itemView.findViewById(R.id.container_output_message);
5252
expandCollapseButton = itemView.findViewById(R.id.expand_collapse_button);

modules/programming/src/main/java/com/symja/programming/document/view/MarkdownVisitor.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -205,7 +205,7 @@ public void visit(FencedCodeBlock fencedCodeBlock) {
205205
CardView cardView = (CardView) view;
206206
cardView.setCardBackgroundColor(editorTheme.getBgColor());
207207
View divider = view.findViewById(R.id.divider);
208-
MaterialButton btnCopy = view.findViewById(R.id.btn_copy);
208+
MaterialButton btnCopy = view.findViewById(R.id.symja_prgm_btn_copy);
209209
if (code.contains(">> ")) {
210210
btnCopy.setVisibility(View.VISIBLE);
211211
btnCopy.setTextColor(editorTheme.getFgColor());

modules/programming/src/main/res/layout/symja_prgm_list_item_markdown_codeblock.xml

+2-2
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@
3535
android:orientation="horizontal">
3636

3737
<com.google.android.material.button.MaterialButton
38-
android:id="@+id/btn_copy"
38+
android:id="@+id/symja_prgm_btn_copy"
3939
style="@style/Widget.MaterialComponents.Button.TextButton"
4040
android:layout_width="wrap_content"
4141
android:layout_height="wrap_content"
@@ -50,7 +50,7 @@
5050
app:iconPadding="0dp" />
5151

5252
<com.google.android.material.button.MaterialButton
53-
android:id="@+id/btn_run"
53+
android:id="@+id/symja_prgm_btn_run"
5454
style="@style/Widget.MaterialComponents.Button.TextButton"
5555
android:layout_width="wrap_content"
5656
android:layout_height="30dp"

modules/programming/src/main/res/layout/symja_prgm_programming_include_input.xml

+10-10
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@
6060
android:orientation="horizontal">
6161

6262
<androidx.appcompat.widget.AppCompatImageView
63-
android:id="@+id/btn_resize_input"
63+
android:id="@+id/symja_prgm_btn_resize_input"
6464
android:layout_width="40dp"
6565
android:layout_height="48dp"
6666
android:background="?selectableItemBackground"
@@ -75,7 +75,7 @@
7575
app:tint="?android:textColorPrimary" />
7676

7777
<androidx.appcompat.widget.AppCompatImageView
78-
android:id="@+id/btn_open_menu"
78+
android:id="@+id/symja_prgm_btn_open_menu"
7979
android:layout_width="40dp"
8080
android:layout_height="48dp"
8181
android:background="?selectableItemBackground"
@@ -88,7 +88,7 @@
8888
app:tint="?android:textColorPrimary" />
8989

9090
<androidx.appcompat.widget.AppCompatImageView
91-
android:id="@+id/btn_copy"
91+
android:id="@+id/symja_prgm_btn_copy"
9292
android:layout_width="40dp"
9393
android:layout_height="48dp"
9494
android:background="?selectableItemBackground"
@@ -104,7 +104,7 @@
104104
app:tint="?android:textColorPrimary" />
105105

106106
<androidx.appcompat.widget.AppCompatImageView
107-
android:id="@+id/btn_paste"
107+
android:id="@+id/symja_prgm_btn_paste"
108108
android:layout_width="40dp"
109109
android:layout_height="48dp"
110110
android:background="?selectableItemBackground"
@@ -120,7 +120,7 @@
120120
app:tint="?android:textColorPrimary" />
121121

122122
<androidx.appcompat.widget.AppCompatImageView
123-
android:id="@+id/btn_undo"
123+
android:id="@+id/symja_prgm_btn_undo"
124124
android:layout_width="40dp"
125125
android:layout_height="48dp"
126126
android:background="?selectableItemBackground"
@@ -136,7 +136,7 @@
136136
app:tint="?android:textColorPrimary" />
137137

138138
<androidx.appcompat.widget.AppCompatImageView
139-
android:id="@+id/btn_redo"
139+
android:id="@+id/symja_prgm_btn_redo"
140140
android:layout_width="40dp"
141141
android:layout_height="48dp"
142142
android:background="?selectableItemBackground"
@@ -154,7 +154,7 @@
154154
</LinearLayout>
155155

156156
<com.google.android.material.button.MaterialButton
157-
android:id="@+id/btn_run"
157+
android:id="@+id/symja_prgm_btn_run"
158158
style="@style/Widget.Material3.Button"
159159
android:layout_width="wrap_content"
160160
android:layout_height="48dp"
@@ -180,7 +180,7 @@
180180
tools:visibility="visible" />
181181

182182
<androidx.appcompat.widget.LinearLayoutCompat
183-
android:id="@+id/error_container"
183+
android:id="@+id/symja_prgm_error_container"
184184
android:layout_width="match_parent"
185185
android:layout_height="match_parent"
186186
android:background="?colorSurface"
@@ -194,7 +194,7 @@
194194
android:fillViewport="true">
195195

196196
<com.google.android.material.textview.MaterialTextView
197-
android:id="@+id/txt_error_message"
197+
android:id="@+id/symja_prgm_txt_error_message"
198198
android:layout_width="match_parent"
199199
android:layout_height="wrap_content"
200200
android:gravity="center_vertical"
@@ -207,7 +207,7 @@
207207
</ScrollView>
208208

209209
<androidx.appcompat.widget.AppCompatImageView
210-
android:id="@+id/btn_close_error_message"
210+
android:id="@+id/symja_prgm_btn_close_error_message"
211211
android:layout_width="wrap_content"
212212
android:layout_height="match_parent"
213213
android:background="?selectableItemBackground"

modules/programming/src/main/res/layout/symja_prgm_programming_list_item_result_footer.xml

+1-1
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@
3737
android:background="@color/symja_prgm_color_list_item_result_stroke" />
3838

3939
<androidx.appcompat.widget.AppCompatTextView
40-
android:id="@+id/txt_error_message"
40+
android:id="@+id/symja_prgm_txt_error_message"
4141
android:layout_width="match_parent"
4242
android:layout_height="wrap_content"
4343
android:paddingLeft="8dp"

modules/programming/src/main/res/menu/symja_prgm_menu_programming_console.xml

+3-3
Original file line numberDiff line numberDiff line change
@@ -3,18 +3,18 @@
33
xmlns:app="http://schemas.android.com/apk/res-auto">
44

55
<item
6-
android:id="@+id/action_import_text_file"
6+
android:id="@+id/symja_prgm_action_import_text_file"
77
android:icon="@drawable/symja_prgm_round_create_new_folder_24"
88
android:title="@string/symja_prgm_menu_import_text_file"
99
app:showAsAction="never" />
1010

1111
<item
12-
android:id="@+id/action_clear_input"
12+
android:id="@+id/symja_prgm_action_clear_input"
1313
android:icon="@drawable/symja_prgm_baseline_clear_24"
1414
android:title="@string/symja_prgm_menu_clear_all_input" />
1515

1616
<item
17-
android:id="@+id/action_clear_all_items"
17+
android:id="@+id/symja_prgm_action_clear_all_items"
1818
android:icon="@drawable/symja_prgm_round_playlist_remove_24"
1919
android:title="@string/symja_prgm_menu_clear_all_items" />
2020

0 commit comments

Comments
 (0)