1/* 2 * Copyright (C) 2016 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License 15 */ 16 17package android.support.v7.app; 18 19import android.content.Context; 20import android.view.KeyboardShortcutGroup; 21import android.view.Menu; 22import android.view.Window; 23 24import java.util.List; 25 26class AppCompatDelegateImplN extends AppCompatDelegateImplV23 { 27 28 AppCompatDelegateImplN(Context context, Window window, AppCompatCallback callback) { 29 super(context, window, callback); 30 } 31 32 @Override 33 Window.Callback wrapWindowCallback(Window.Callback callback) { 34 return new AppCompatWindowCallbackN(callback); 35 } 36 37 class AppCompatWindowCallbackN extends AppCompatWindowCallbackV23 { 38 AppCompatWindowCallbackN(Window.Callback callback) { 39 super(callback); 40 } 41 42 @Override 43 public void onProvideKeyboardShortcuts( 44 List<KeyboardShortcutGroup> data, Menu menu, int deviceId) { 45 final PanelFeatureState panel = getPanelState(Window.FEATURE_OPTIONS_PANEL, true); 46 if (panel != null && panel.menu != null) { 47 // The menu provided is one created by PhoneWindow which we don't actually use. 48 // Instead we'll pass through our own... 49 super.onProvideKeyboardShortcuts(data, panel.menu, deviceId); 50 } else { 51 // If we don't have a menu, jump pass through the original instead 52 super.onProvideKeyboardShortcuts(data, menu, deviceId); 53 } 54 } 55 } 56} 57