]> gitweb.fperrin.net Git - Dictionary.git/commitdiff
Make QuickDic handle ACTION_PROCESS_TEXT
authorSebastian Doerner <sebastian@sebastian-doerner.de>
Sat, 16 Jul 2016 03:18:45 +0000 (23:18 -0400)
committerReimar Döffinger <Reimar.Doeffinger@gmx.de>
Thu, 27 Oct 2016 21:24:10 +0000 (23:24 +0200)
This shows QuickDic as an option in the text selection context menu of
other apps.

See
https://medium.com/google-developers/custom-text-selection-actions-with-action-process-text-191f792d2999

AndroidManifest.xml
src/com/hughes/android/dictionary/DictionaryActivity.java

index becf18e2d48b6683b0ac4ab83cd863f372c61ca9..1cac12a3b22ef2aeed1838375cca978b7766493c 100644 (file)
            @author Dominik Köppl
                        Added two different intents to catch simple and advanced queries from other external applications.
             -->
+            <intent-filter>
+                <action android:name="android.intent.action.PROCESS_TEXT" />
+                <category android:name="android.intent.category.DEFAULT" />
+                <data android:mimeType="text/plain" />
+            </intent-filter>
             <intent-filter>
                 <action android:name="android.intent.action.SEARCH" />
 
index 356e957ebaf8788645e898a1ac3d6b801ba04e7b..2bfb8c1089f0e4ff4be51e3c00faa18cace4121a 100644 (file)
@@ -300,6 +300,15 @@ public class DictionaryActivity extends ActionBarActivity {
             if (query != null)
                 getIntent().putExtra(C.SEARCH_TOKEN, query);
         }
+        /*
+         * This processes text on M+ devices where QuickDic shows up in the context menu.
+         */
+        if (intentAction != null && intentAction.equals(Intent.ACTION_PROCESS_TEXT)) {
+            String query = intent.getStringExtra(Intent.EXTRA_PROCESS_TEXT);
+            if (query != null) {
+                getIntent().putExtra(C.SEARCH_TOKEN, query);
+            }
+        }
         /**
          * @author Dominik Köppl If no dictionary is chosen, use the default
          *         dictionary specified in the preferences If this step does