From 96b9454a3a7222fa1c90109000c95a171af8b61a Mon Sep 17 00:00:00 2001 From: Sebastian Doerner Date: Fri, 15 Jul 2016 23:18:45 -0400 Subject: [PATCH] Make QuickDic handle ACTION_PROCESS_TEXT 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 | 5 +++++ .../hughes/android/dictionary/DictionaryActivity.java | 9 +++++++++ 2 files changed, 14 insertions(+) diff --git a/AndroidManifest.xml b/AndroidManifest.xml index becf18e..1cac12a 100644 --- a/AndroidManifest.xml +++ b/AndroidManifest.xml @@ -62,6 +62,11 @@ @author Dominik Köppl Added two different intents to catch simple and advanced queries from other external applications. --> + + + + + diff --git a/src/com/hughes/android/dictionary/DictionaryActivity.java b/src/com/hughes/android/dictionary/DictionaryActivity.java index 356e957..2bfb8c1 100644 --- a/src/com/hughes/android/dictionary/DictionaryActivity.java +++ b/src/com/hughes/android/dictionary/DictionaryActivity.java @@ -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 -- 2.43.0