Skip to content

Commit

Permalink
Fix soft keyboard not show after clicking "Clear input" item
Browse files Browse the repository at this point in the history
  • Loading branch information
duy committed Oct 29, 2024
1 parent fd4829d commit 5195e2e
Show file tree
Hide file tree
Showing 7 changed files with 34 additions and 32 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ private void setupViews(@NonNull View view) {
private void addViewEvents(@NotNull View view) {
btnRun.setOnClickListener(v -> clickRun());

View btnCopy = view.findViewById(R.id.btn_copy);
View btnCopy = view.findViewById(R.id.symja_prgm_btn_copy);
btnCopy.setOnClickListener(v -> {
final Context context = getContext();
String content = inputView.getText().toString();
Expand All @@ -133,7 +133,7 @@ private void addViewEvents(@NotNull View view) {
ViewUtils.showToast(context, R.string.symja_prgm_message_copied, ViewUtils.LENGTH_SHORT);
}
});
view.findViewById(R.id.btn_paste).setOnClickListener(v -> {
view.findViewById(R.id.symja_prgm_btn_paste).setOnClickListener(v -> {
final Context context = getContext();
CharSequence clipboard = ClipboardCompat.getClipboard(context);
if (clipboard != null) {
Expand All @@ -144,13 +144,13 @@ private void addViewEvents(@NotNull View view) {
ViewUtils.showKeyboard(context, inputView);
}
});
View btnUndo = view.findViewById(R.id.btn_undo);
View btnUndo = view.findViewById(R.id.symja_prgm_btn_undo);
btnUndo.setOnClickListener(v -> {
if (inputView.canUndo()) {
inputView.undo();
}
});
View btnRedo = view.findViewById(R.id.btn_redo);
View btnRedo = view.findViewById(R.id.symja_prgm_btn_redo);
btnRedo.setOnClickListener(v -> {
if (inputView.canRedo()) {
inputView.redo();
Expand Down Expand Up @@ -369,9 +369,9 @@ public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceStat
}
});

txtErrorLabel = view.findViewById(R.id.txt_error_message);
errorContainer = view.findViewById(R.id.error_container);
btnCloseError = view.findViewById(R.id.btn_close_error_message);
txtErrorLabel = view.findViewById(R.id.symja_prgm_txt_error_message);
errorContainer = view.findViewById(R.id.symja_prgm_error_container);
btnCloseError = view.findViewById(R.id.symja_prgm_btn_close_error_message);
errorContainer.setVisibility(View.GONE);
btnCloseError.setOnClickListener(v -> errorContainer.setVisibility(View.GONE));

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

btnRun = view.findViewById(R.id.btn_run);
btnRun = view.findViewById(R.id.symja_prgm_btn_run);
progressBar = view.findViewById(R.id.progress_bar);
progressBar.setVisibility(View.GONE);

setupViews(view);
addViewEvents(view);
setupSymbolViews(view.findViewById(R.id.container_symbol), view);

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

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

view.findViewById(R.id.btn_open_menu).setOnClickListener(this::openMenu);
view.findViewById(R.id.symja_prgm_btn_open_menu).setOnClickListener(this::openMenu);
}

private void openMenu(View v) {
Expand All @@ -431,17 +431,19 @@ private void openMenu(View v) {
popupMenu.inflate(R.menu.symja_prgm_menu_programming_console, v);
popupMenu.setOnMenuItemClickListener(item -> {
int itemId = item.getItemId();
if (itemId == R.id.action_clear_all_items) {
if (itemId == R.id.symja_prgm_action_clear_all_items) {
clickClearAll();
return true;
}
if (itemId == R.id.action_clear_input) {
if (itemId == R.id.symja_prgm_action_clear_input) {
final Context context = requireContext();
inputView.setText("");
inputView.requestFocus();
ViewUtils.showKeyboard(context, inputView);
inputView.postDelayed(() -> {
ViewUtils.showKeyboard(context, inputView);
}, 500);
return true;
} else if (itemId == R.id.action_import_text_file) {
} else if (itemId == R.id.symja_prgm_action_import_text_file) {
importTextFile();
return true;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ public abstract class BaseViewHolder extends RecyclerView.ViewHolder {
super(itemView);
txtTitle = itemView.findViewById(R.id.txt_title);

txtErrorMessage = itemView.findViewById(R.id.txt_error_message);
txtErrorMessage = itemView.findViewById(R.id.symja_prgm_txt_error_message);
txtStandardMessage = itemView.findViewById(R.id.txt_standard_message);
containerMessage = itemView.findViewById(R.id.container_output_message);
expandCollapseButton = itemView.findViewById(R.id.expand_collapse_button);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,7 @@ public void visit(FencedCodeBlock fencedCodeBlock) {
CardView cardView = (CardView) view;
cardView.setCardBackgroundColor(editorTheme.getBgColor());
View divider = view.findViewById(R.id.divider);
MaterialButton btnCopy = view.findViewById(R.id.btn_copy);
MaterialButton btnCopy = view.findViewById(R.id.symja_prgm_btn_copy);
if (code.contains(">> ")) {
btnCopy.setVisibility(View.VISIBLE);
btnCopy.setTextColor(editorTheme.getFgColor());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
android:orientation="horizontal">

<com.google.android.material.button.MaterialButton
android:id="@+id/btn_copy"
android:id="@+id/symja_prgm_btn_copy"
style="@style/Widget.MaterialComponents.Button.TextButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
Expand All @@ -50,7 +50,7 @@
app:iconPadding="0dp" />

<com.google.android.material.button.MaterialButton
android:id="@+id/btn_run"
android:id="@+id/symja_prgm_btn_run"
style="@style/Widget.MaterialComponents.Button.TextButton"
android:layout_width="wrap_content"
android:layout_height="30dp"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@
android:orientation="horizontal">

<androidx.appcompat.widget.AppCompatImageView
android:id="@+id/btn_resize_input"
android:id="@+id/symja_prgm_btn_resize_input"
android:layout_width="40dp"
android:layout_height="48dp"
android:background="?selectableItemBackground"
Expand All @@ -75,7 +75,7 @@
app:tint="?android:textColorPrimary" />

<androidx.appcompat.widget.AppCompatImageView
android:id="@+id/btn_open_menu"
android:id="@+id/symja_prgm_btn_open_menu"
android:layout_width="40dp"
android:layout_height="48dp"
android:background="?selectableItemBackground"
Expand All @@ -88,7 +88,7 @@
app:tint="?android:textColorPrimary" />

<androidx.appcompat.widget.AppCompatImageView
android:id="@+id/btn_copy"
android:id="@+id/symja_prgm_btn_copy"
android:layout_width="40dp"
android:layout_height="48dp"
android:background="?selectableItemBackground"
Expand All @@ -104,7 +104,7 @@
app:tint="?android:textColorPrimary" />

<androidx.appcompat.widget.AppCompatImageView
android:id="@+id/btn_paste"
android:id="@+id/symja_prgm_btn_paste"
android:layout_width="40dp"
android:layout_height="48dp"
android:background="?selectableItemBackground"
Expand All @@ -120,7 +120,7 @@
app:tint="?android:textColorPrimary" />

<androidx.appcompat.widget.AppCompatImageView
android:id="@+id/btn_undo"
android:id="@+id/symja_prgm_btn_undo"
android:layout_width="40dp"
android:layout_height="48dp"
android:background="?selectableItemBackground"
Expand All @@ -136,7 +136,7 @@
app:tint="?android:textColorPrimary" />

<androidx.appcompat.widget.AppCompatImageView
android:id="@+id/btn_redo"
android:id="@+id/symja_prgm_btn_redo"
android:layout_width="40dp"
android:layout_height="48dp"
android:background="?selectableItemBackground"
Expand All @@ -154,7 +154,7 @@
</LinearLayout>

<com.google.android.material.button.MaterialButton
android:id="@+id/btn_run"
android:id="@+id/symja_prgm_btn_run"
style="@style/Widget.Material3.Button"
android:layout_width="wrap_content"
android:layout_height="48dp"
Expand All @@ -180,7 +180,7 @@
tools:visibility="visible" />

<androidx.appcompat.widget.LinearLayoutCompat
android:id="@+id/error_container"
android:id="@+id/symja_prgm_error_container"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="?colorSurface"
Expand All @@ -194,7 +194,7 @@
android:fillViewport="true">

<com.google.android.material.textview.MaterialTextView
android:id="@+id/txt_error_message"
android:id="@+id/symja_prgm_txt_error_message"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center_vertical"
Expand All @@ -207,7 +207,7 @@
</ScrollView>

<androidx.appcompat.widget.AppCompatImageView
android:id="@+id/btn_close_error_message"
android:id="@+id/symja_prgm_btn_close_error_message"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:background="?selectableItemBackground"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
android:background="@color/symja_prgm_color_list_item_result_stroke" />

<androidx.appcompat.widget.AppCompatTextView
android:id="@+id/txt_error_message"
android:id="@+id/symja_prgm_txt_error_message"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingLeft="8dp"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,18 @@
xmlns:app="http://schemas.android.com/apk/res-auto">

<item
android:id="@+id/action_import_text_file"
android:id="@+id/symja_prgm_action_import_text_file"
android:icon="@drawable/symja_prgm_round_create_new_folder_24"
android:title="@string/symja_prgm_menu_import_text_file"
app:showAsAction="never" />

<item
android:id="@+id/action_clear_input"
android:id="@+id/symja_prgm_action_clear_input"
android:icon="@drawable/symja_prgm_baseline_clear_24"
android:title="@string/symja_prgm_menu_clear_all_input" />

<item
android:id="@+id/action_clear_all_items"
android:id="@+id/symja_prgm_action_clear_all_items"
android:icon="@drawable/symja_prgm_round_playlist_remove_24"
android:title="@string/symja_prgm_menu_clear_all_items" />

Expand Down

0 comments on commit 5195e2e

Please sign in to comment.