Merge "Expose the Keyboard Shortcuts Helper in Activity" into nyc-dev

This commit is contained in:
Clara Bayarri
2016-04-11 09:43:14 +00:00
committed by Android (Google) Code Review
7 changed files with 64 additions and 0 deletions

View File

@@ -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);

View File

@@ -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);

View File

@@ -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);

View File

@@ -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) {

View File

@@ -1403,6 +1403,16 @@ public class Intent implements Parcelable, Cloneable {
@SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
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

View File

@@ -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>

View File

@@ -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 */);
}
}
}