1/* 2 * Copyright (C) 2014 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.internal.view; 18 19import android.view.ActionMode; 20import android.view.KeyEvent; 21import android.view.Menu; 22import android.view.MenuItem; 23import android.view.MotionEvent; 24import android.view.SearchEvent; 25import android.view.View; 26import android.view.Window; 27import android.view.WindowManager; 28import android.view.accessibility.AccessibilityEvent; 29 30/** 31 * A simple decorator stub for Window.Callback that passes through any calls 32 * to the wrapped instance as a base implementation. Call super.foo() to call into 33 * the wrapped callback for any subclasses. 34 * 35 * @hide 36 */ 37public class WindowCallbackWrapper implements Window.Callback { 38 39 final Window.Callback mWrapped; 40 41 public WindowCallbackWrapper(Window.Callback wrapped) { 42 if (wrapped == null) { 43 throw new IllegalArgumentException("Window callback may not be null"); 44 } 45 mWrapped = wrapped; 46 } 47 48 @Override 49 public boolean dispatchKeyEvent(KeyEvent event) { 50 return mWrapped.dispatchKeyEvent(event); 51 } 52 53 @Override 54 public boolean dispatchKeyShortcutEvent(KeyEvent event) { 55 return mWrapped.dispatchKeyShortcutEvent(event); 56 } 57 58 @Override 59 public boolean dispatchTouchEvent(MotionEvent event) { 60 return mWrapped.dispatchTouchEvent(event); 61 } 62 63 @Override 64 public boolean dispatchTrackballEvent(MotionEvent event) { 65 return mWrapped.dispatchTrackballEvent(event); 66 } 67 68 @Override 69 public boolean dispatchGenericMotionEvent(MotionEvent event) { 70 return mWrapped.dispatchGenericMotionEvent(event); 71 } 72 73 @Override 74 public boolean dispatchPopulateAccessibilityEvent(AccessibilityEvent event) { 75 return mWrapped.dispatchPopulateAccessibilityEvent(event); 76 } 77 78 @Override 79 public View onCreatePanelView(int featureId) { 80 return mWrapped.onCreatePanelView(featureId); 81 } 82 83 @Override 84 public boolean onCreatePanelMenu(int featureId, Menu menu) { 85 return mWrapped.onCreatePanelMenu(featureId, menu); 86 } 87 88 @Override 89 public boolean onPreparePanel(int featureId, View view, Menu menu) { 90 return mWrapped.onPreparePanel(featureId, view, menu); 91 } 92 93 @Override 94 public boolean onMenuOpened(int featureId, Menu menu) { 95 return mWrapped.onMenuOpened(featureId, menu); 96 } 97 98 @Override 99 public boolean onMenuItemSelected(int featureId, MenuItem item) { 100 return mWrapped.onMenuItemSelected(featureId, item); 101 } 102 103 @Override 104 public void onWindowAttributesChanged(WindowManager.LayoutParams attrs) { 105 mWrapped.onWindowAttributesChanged(attrs); 106 } 107 108 @Override 109 public void onContentChanged() { 110 mWrapped.onContentChanged(); 111 } 112 113 @Override 114 public void onWindowFocusChanged(boolean hasFocus) { 115 mWrapped.onWindowFocusChanged(hasFocus); 116 } 117 118 @Override 119 public void onAttachedToWindow() { 120 mWrapped.onAttachedToWindow(); 121 } 122 123 @Override 124 public void onDetachedFromWindow() { 125 mWrapped.onDetachedFromWindow(); 126 } 127 128 @Override 129 public void onPanelClosed(int featureId, Menu menu) { 130 mWrapped.onPanelClosed(featureId, menu); 131 } 132 133 @Override 134 public boolean onSearchRequested(SearchEvent searchEvent) { 135 return mWrapped.onSearchRequested(searchEvent); 136 } 137 138 @Override 139 public boolean onSearchRequested() { 140 return mWrapped.onSearchRequested(); 141 } 142 143 @Override 144 public ActionMode onWindowStartingActionMode(ActionMode.Callback callback) { 145 return mWrapped.onWindowStartingActionMode(callback); 146 } 147 148 @Override 149 public ActionMode onWindowStartingActionMode(ActionMode.Callback callback, int type) { 150 return mWrapped.onWindowStartingActionMode(callback, type); 151 } 152 153 @Override 154 public void onActionModeStarted(ActionMode mode) { 155 mWrapped.onActionModeStarted(mode); 156 } 157 158 @Override 159 public void onActionModeFinished(ActionMode mode) { 160 mWrapped.onActionModeFinished(mode); 161 } 162} 163