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