diff options
| -rw-r--r-- | api/current.txt | 1 | ||||
| -rw-r--r-- | api/system-current.txt | 1 | ||||
| -rw-r--r-- | api/test-current.txt | 1 | ||||
| -rw-r--r-- | core/java/android/app/Activity.java | 11 | ||||
| -rw-r--r-- | core/java/android/content/Intent.java | 10 | ||||
| -rw-r--r-- | packages/SystemUI/AndroidManifest.xml | 7 | ||||
| -rw-r--r-- | packages/SystemUI/src/com/android/systemui/statusbar/KeyboardShortcutsReceiver.java | 33 |
7 files changed, 64 insertions, 0 deletions
diff --git a/api/current.txt b/api/current.txt index 34445974ba2a..fbbb2e379743 100644 --- a/api/current.txt +++ b/api/current.txt @@ -3578,6 +3578,7 @@ package android.app { method public final deprecated void removeDialog(int); method public void reportFullyDrawn(); method public android.view.DropPermissions requestDropPermissions(android.view.DragEvent); + method public final void requestKeyboardShortcutsHelper(); method public final void requestPermissions(java.lang.String[], int); method public boolean requestVisibleBehind(boolean); method public final boolean requestWindowFeature(int); diff --git a/api/system-current.txt b/api/system-current.txt index a4927f2ac578..d91f5d18a52c 100644 --- a/api/system-current.txt +++ b/api/system-current.txt @@ -3696,6 +3696,7 @@ package android.app { method public final deprecated void removeDialog(int); method public void reportFullyDrawn(); method public android.view.DropPermissions requestDropPermissions(android.view.DragEvent); + method public final void requestKeyboardShortcutsHelper(); method public final void requestPermissions(java.lang.String[], int); method public boolean requestVisibleBehind(boolean); method public final boolean requestWindowFeature(int); diff --git a/api/test-current.txt b/api/test-current.txt index 41799480a668..bad973359337 100644 --- a/api/test-current.txt +++ b/api/test-current.txt @@ -3578,6 +3578,7 @@ package android.app { method public final deprecated void removeDialog(int); method public void reportFullyDrawn(); method public android.view.DropPermissions requestDropPermissions(android.view.DragEvent); + method public final void requestKeyboardShortcutsHelper(); method public final void requestPermissions(java.lang.String[], int); method public boolean requestVisibleBehind(boolean); method public final boolean requestWindowFeature(int); diff --git a/core/java/android/app/Activity.java b/core/java/android/app/Activity.java index 672a70618fab..76527667c62e 100644 --- a/core/java/android/app/Activity.java +++ b/core/java/android/app/Activity.java @@ -1676,6 +1676,17 @@ public class Activity extends ContextThemeWrapper public void onProvideAssistContent(AssistContent outContent) { } + /** + * Request the Keyboard Shortcuts screen to show up. If it succeeds, this will trigger + * {@link #onProvideKeyboardShortcuts} to retrieve the shortcuts for the foreground activity. + */ + public final void requestKeyboardShortcutsHelper() { + Intent intent = new Intent(Intent.ACTION_SHOW_KEYBOARD_SHORTCUTS); + intent.setComponent(new ComponentName("com.android.systemui", + "com.android.systemui.statusbar.KeyboardShortcutsReceiver")); + sendBroadcast(intent); + } + @Override public void onProvideKeyboardShortcuts( List<KeyboardShortcutGroup> data, Menu menu, int deviceId) { diff --git a/core/java/android/content/Intent.java b/core/java/android/content/Intent.java index 207b70af3f60..7e67e8d7e6a4 100644 --- a/core/java/android/content/Intent.java +++ b/core/java/android/content/Intent.java @@ -1404,6 +1404,16 @@ public class Intent implements Parcelable, Cloneable { public static final String ACTION_UPGRADE_SETUP = "android.intent.action.UPGRADE_SETUP"; /** + * Activity Action: Start the Keyboard Shortcuts Helper screen. + * <p>Input: Nothing. + * <p>Output: Nothing. + * @hide + */ + @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) + public static final String ACTION_SHOW_KEYBOARD_SHORTCUTS = + "android.intent.action.SHOW_KEYBOARD_SHORTCUTS"; + + /** * Activity Action: Show settings for managing network data usage of a * specific application. Applications should define an activity that offers * options to control data usage. diff --git a/packages/SystemUI/AndroidManifest.xml b/packages/SystemUI/AndroidManifest.xml index 9e2442cc2357..f5854f5f7a36 100644 --- a/packages/SystemUI/AndroidManifest.xml +++ b/packages/SystemUI/AndroidManifest.xml @@ -488,5 +488,12 @@ <action android:name="com.android.systemui.action.CLEAR_TUNER" /> </intent-filter> </receiver> + + <receiver + android:name=".statusbar.KeyboardShortcutsReceiver"> + <intent-filter> + <action android:name="android.intent.action.SHOW_KEYBOARD_SHORTCUTS" /> + </intent-filter> + </receiver> </application> </manifest> diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/KeyboardShortcutsReceiver.java b/packages/SystemUI/src/com/android/systemui/statusbar/KeyboardShortcutsReceiver.java new file mode 100644 index 000000000000..5d22faf2d4ce --- /dev/null +++ b/packages/SystemUI/src/com/android/systemui/statusbar/KeyboardShortcutsReceiver.java @@ -0,0 +1,33 @@ +/* + * Copyright (C) 2016 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 com.android.systemui.statusbar; + +import android.content.BroadcastReceiver; +import android.content.Context; +import android.content.Intent; + +/** + * Receiver for the Keyboard Shortcuts Helper. + */ +public class KeyboardShortcutsReceiver extends BroadcastReceiver { + @Override + public void onReceive(Context context, Intent intent) { + if (Intent.ACTION_SHOW_KEYBOARD_SHORTCUTS.equals(intent.getAction())) { + final KeyboardShortcuts keyboardShortcuts = new KeyboardShortcuts(context); + keyboardShortcuts.toggleKeyboardShortcuts(-1 /* deviceId unknown */); + } + } +} |