Add process text action
app/src/main/AndroidManifest.xml
| 93 | 93 | <action android:name="android.intent.action.MAIN" /> | |
| 94 | 94 | <category android:name="android.intent.category.LAUNCHER" /> | |
| 95 | 95 | </intent-filter> | |
| 96 | + | <intent-filter> | |
| 97 | + | <action android:name="android.intent.action.PROCESS_TEXT" /> | |
| 98 | + | <category android:name="android.intent.category.DEFAULT" /> | |
| 99 | + | <data android:mimeType="text/plain" /> | |
| 100 | + | </intent-filter> | |
| 96 | 101 | </activity> | |
| 97 | 102 | <service android:name=".DictionaryDownloadService" /> | |
| 98 | 103 | </application> |
app/src/main/java/eu/lepiller/nani/MainActivity.java
| 45 | 45 | private SearchView search_form; | |
| 46 | 46 | private RadicalSelectorView radical_selector; | |
| 47 | 47 | private String readingStyle = "furigana"; | |
| 48 | + | private String intentSearch = null; | |
| 48 | 49 | ViewPager2 viewPager2; | |
| 49 | 50 | ResultPagerAdapter pagerAdapter; | |
| 50 | 51 | ||
… | |||
| 133 | 134 | startActivity(intent); | |
| 134 | 135 | } | |
| 135 | 136 | }); | |
| 137 | + | ||
| 138 | + | if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.M) { | |
| 139 | + | CharSequence searchTerm = getIntent().getCharSequenceExtra(Intent.EXTRA_PROCESS_TEXT); | |
| 140 | + | if(searchTerm != null && !searchTerm.toString().isEmpty()) | |
| 141 | + | intentSearch = searchTerm.toString(); | |
| 142 | + | } | |
| 136 | 143 | } | |
| 137 | 144 | ||
| 138 | 145 | private void closeRadicals() { | |
… | |||
| 362 | 369 | } | |
| 363 | 370 | ||
| 364 | 371 | @Override | |
| 372 | + | public boolean onPrepareOptionsMenu(Menu menu) { | |
| 373 | + | if(intentSearch != null) { | |
| 374 | + | search_form.setQuery(intentSearch, true); | |
| 375 | + | intentSearch = null; | |
| 376 | + | } | |
| 377 | + | return super.onPrepareOptionsMenu(menu); | |
| 378 | + | } | |
| 379 | + | ||
| 380 | + | @Override | |
| 365 | 381 | public boolean onOptionsItemSelected(MenuItem item) { | |
| 366 | 382 | // Handle action bar item clicks here. The action bar will | |
| 367 | 383 | // automatically handle clicks on the Home/Up button, so long | |