]> gitweb.fperrin.net Git - Dictionary.git/blobdiff - src/com/hughes/android/dictionary/DictionaryActivity.java
Show dictionary list on normal click.
[Dictionary.git] / src / com / hughes / android / dictionary / DictionaryActivity.java
index 2bfb8c1089f0e4ff4be51e3c00faa18cace4121a..4b147141dd6c8507cb2618893919cc0a62d1500c 100644 (file)
@@ -28,6 +28,7 @@ import android.os.Handler;
 import android.preference.PreferenceManager;
 import android.speech.tts.TextToSpeech;
 import android.speech.tts.TextToSpeech.OnInitListener;
+import android.support.design.widget.FloatingActionButton;
 import android.support.v4.view.MenuItemCompat;
 import android.support.v7.app.ActionBar;
 import android.support.v7.app.ActionBarActivity;
@@ -300,6 +301,12 @@ public class DictionaryActivity extends ActionBarActivity {
             if (query != null)
                 getIntent().putExtra(C.SEARCH_TOKEN, query);
         }
+        if (intentAction != null && intentAction.equals(Intent.ACTION_SEND))
+        {
+            String query = intent.getStringExtra(Intent.EXTRA_TEXT);
+            if (query != null)
+                getIntent().putExtra(C.SEARCH_TOKEN, query);
+        }
         /*
          * This processes text on M+ devices where QuickDic shows up in the context menu.
          */
@@ -473,6 +480,21 @@ public class DictionaryActivity extends ActionBarActivity {
             }
         });
 
+        final FloatingActionButton floatSearchButton = (FloatingActionButton)findViewById(R.id.floatSearchButton);
+        floatSearchButton.setOnClickListener(new OnClickListener() {
+            @Override
+            public void onClick(View arg0) {
+                if (!searchView.hasFocus()) {
+                    searchView.requestFocus();
+                }
+                if (searchView.getQuery().toString().length() > 0) {
+                    searchView.setQuery("", false);
+                }
+                showKeyboard();
+                searchView.setIconified(false);
+            }
+        });
+
         // Set the search text from the intent, then the saved state.
         String text = getIntent().getStringExtra(C.SEARCH_TOKEN);
         if (savedInstanceState != null) {
@@ -516,15 +538,8 @@ public class DictionaryActivity extends ActionBarActivity {
         languageButton.setScaleType(ScaleType.FIT_CENTER);
         languageButton.setOnClickListener(new OnClickListener() {
             @Override
-            public void onClick(View arg0) {
-                onLanguageButtonClick();
-            }
-        });
-        languageButton.setOnLongClickListener(new OnLongClickListener() {
-            @Override
-            public boolean onLongClick(View v) {
+            public void onClick(View v) {
                 onLanguageButtonLongClick(v.getContext());
-                return true;
             }
         });
         languageButton.setAdjustViewBounds(true);
@@ -1666,6 +1681,7 @@ public class DictionaryActivity extends ActionBarActivity {
         }
         currentSearchOperation = new SearchOperation(text, index);
         searchExecutor.execute(currentSearchOperation);
+        ((FloatingActionButton)findViewById(R.id.floatSearchButton)).setImageResource(text.length() > 0 ? R.drawable.ic_clear_black_24dp : R.drawable.ic_search_black_24dp);
     }
 
     // --------------------------------------------------------------------------