|
22 | 22 | import android.view.View; |
23 | 23 | import android.view.ViewGroup; |
24 | 24 | import android.view.inputmethod.EditorInfo; |
| 25 | +import android.view.inputmethod.InputMethodManager; |
25 | 26 |
|
26 | 27 | import androidx.activity.OnBackPressedCallback; |
27 | 28 | import androidx.activity.result.ActivityResultLauncher; |
@@ -222,7 +223,9 @@ private void setupSearchView(@Nullable SearchManager searchManager, ComponentNam |
222 | 223 | binding.searchView.setIconifiedByDefault(false); |
223 | 224 | binding.searchView.setImeOptions(EditorInfo.IME_FLAG_NO_EXTRACT_UI); |
224 | 225 | binding.searchView.setQueryHint(getResources().getString(R.string.note_share_activity_search_text)); |
225 | | - binding.searchView.setInputType(InputType.TYPE_NULL); |
| 226 | + binding.searchView.setInputType(InputType.TYPE_CLASS_TEXT); |
| 227 | + binding.searchView.setFocusable(true); |
| 228 | + binding.searchView.setFocusableInTouchMode(true); |
226 | 229 |
|
227 | 230 | View closeButton = binding.searchView.findViewById(androidx.appcompat.R.id.search_close_btn); |
228 | 231 | closeButton.setOnClickListener(v -> { |
@@ -284,6 +287,13 @@ public boolean onQueryTextChange(String newText) { |
284 | 287 | } |
285 | 288 | }); |
286 | 289 |
|
| 290 | + binding.searchView.setOnQueryTextFocusChangeListener((v, hasFocus) -> { |
| 291 | + if (hasFocus) { |
| 292 | + InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE); |
| 293 | + imm.showSoftInput(binding.searchView.findFocus(), InputMethodManager.SHOW_IMPLICIT); |
| 294 | + } |
| 295 | + }); |
| 296 | + |
287 | 297 | binding.searchView.setOnSuggestionListener(new SearchView.OnSuggestionListener() { |
288 | 298 | @Override |
289 | 299 | public boolean onSuggestionSelect(int position) { |
|
0 commit comments