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.support.annotation.RequiresApi; 21import android.view.KeyboardShortcutGroup; 22import android.view.Menu; 23import android.view.Window; 24 25import java.util.List; 26 27@RequiresApi(24) 28class AppCompatDelegateImplN extends AppCompatDelegateImplV23 { 29 30 AppCompatDelegateImplN(Context context, Window window, AppCompatCallback callback) { 31 super(context, window, callback); 32 } 33 34 @Override 35 Window.Callback wrapWindowCallback(Window.Callback callback) { 36 return new AppCompatWindowCallbackN(callback); 37 } 38 39 class AppCompatWindowCallbackN extends AppCompatWindowCallbackV23 { 40 AppCompatWindowCallbackN(Window.Callback callback) { 41 super(callback); 42 } 43 44 @Override 45 public void onProvideKeyboardShortcuts( 46 List<KeyboardShortcutGroup> data, Menu menu, int deviceId) { 47 final PanelFeatureState panel = getPanelState(Window.FEATURE_OPTIONS_PANEL, true); 48 if (panel != null && panel.menu != null) { 49 // The menu provided is one created by PhoneWindow which we don't actually use. 50 // Instead we'll pass through our own... 51 super.onProvideKeyboardShortcuts(data, panel.menu, deviceId); 52 } else { 53 // If we don't have a menu, jump pass through the original instead 54 super.onProvideKeyboardShortcuts(data, menu, deviceId); 55 } 56 } 57 } 58} 59