diff options
Diffstat (limited to 'core/java/android/view')
-rw-r--r-- | core/java/android/view/PhoneWindow.java | 11 | ||||
-rw-r--r-- | core/java/android/view/SearchEvent.java | 40 | ||||
-rw-r--r-- | core/java/android/view/Window.java | 9 | ||||
-rw-r--r-- | core/java/android/view/WindowCallbackWrapper.java | 5 |
4 files changed, 62 insertions, 3 deletions
diff --git a/core/java/android/view/PhoneWindow.java b/core/java/android/view/PhoneWindow.java index 38f4d1c..5af2832 100644 --- a/core/java/android/view/PhoneWindow.java +++ b/core/java/android/view/PhoneWindow.java @@ -1916,7 +1916,7 @@ public class PhoneWindow extends Window implements MenuBuilder.Callback { break; } if (event.isTracking() && !event.isCanceled()) { - launchDefaultSearch(); + launchDefaultSearch(event); } return true; } @@ -4245,14 +4245,19 @@ public class PhoneWindow extends Window implements MenuBuilder.Callback { * * @return true if search window opened */ - private boolean launchDefaultSearch() { + private boolean launchDefaultSearch(KeyEvent event) { boolean result; final Callback cb = getCallback(); if (cb == null || isDestroyed()) { result = false; } else { sendCloseSystemWindows("search"); - result = cb.onSearchRequested(); + int deviceId = event.getDeviceId(); + SearchEvent searchEvent = null; + if (deviceId != 0) { + searchEvent = new SearchEvent(InputDevice.getDevice(deviceId)); + } + result = cb.onSearchRequested(searchEvent); } if (!result && (getContext().getResources().getConfiguration().uiMode & Configuration.UI_MODE_TYPE_MASK) == Configuration.UI_MODE_TYPE_TELEVISION) { diff --git a/core/java/android/view/SearchEvent.java b/core/java/android/view/SearchEvent.java new file mode 100644 index 0000000..ef51e7d --- /dev/null +++ b/core/java/android/view/SearchEvent.java @@ -0,0 +1,40 @@ +/* + * Copyright (C) 2015 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package android.view; + +import android.view.InputDevice; + +/** + * Class that contains information about an event that triggers a search. + */ +public class SearchEvent { + + private InputDevice mInputDevice; + + /** @hide */ + public SearchEvent(InputDevice inputDevice) { + mInputDevice = inputDevice; + } + + /** + * Returns the {@link InputDevice} that triggered the search. + * @return InputDevice the InputDevice that triggered the search. + */ + public InputDevice getInputDevice() { + return mInputDevice; + } +} diff --git a/core/java/android/view/Window.java b/core/java/android/view/Window.java index 36f047e..9d0d5ff 100644 --- a/core/java/android/view/Window.java +++ b/core/java/android/view/Window.java @@ -414,6 +414,15 @@ public abstract class Window { public boolean onSearchRequested(); /** + * Called when the user signals the desire to start a search. + * + * @param searchEvent A {@link SearchEvent} describing the signal to + * start a search. + * @return true if search launched, false if activity refuses (blocks) + */ + public boolean onSearchRequested(SearchEvent searchEvent); + + /** * Called when an action mode is being started for this window. Gives the * callback an opportunity to handle the action mode in its own unique and * beautiful way. If this method returns null the system can choose a way diff --git a/core/java/android/view/WindowCallbackWrapper.java b/core/java/android/view/WindowCallbackWrapper.java index 979ee95..8ce1f8c 100644 --- a/core/java/android/view/WindowCallbackWrapper.java +++ b/core/java/android/view/WindowCallbackWrapper.java @@ -122,6 +122,11 @@ public class WindowCallbackWrapper implements Window.Callback { } @Override + public boolean onSearchRequested(SearchEvent searchEvent) { + return mWrapped.onSearchRequested(searchEvent); + } + + @Override public boolean onSearchRequested() { return mWrapped.onSearchRequested(); } |