1 // Copyright 2014 The Chromium Authors. All rights reserved. 2 // Use of this source code is governed by a BSD-style license that can be 3 // found in the LICENSE file. 4 5 package org.chromium.base; 6 7 import android.annotation.SuppressLint; 8 import android.view.ActionMode; 9 import android.view.ActionMode.Callback; 10 import android.view.KeyEvent; 11 import android.view.Menu; 12 import android.view.MenuItem; 13 import android.view.MotionEvent; 14 import android.view.View; 15 import android.view.Window; 16 import android.view.WindowManager.LayoutParams; 17 import android.view.accessibility.AccessibilityEvent; 18 19 /** 20 * A wrapper for a Window.Callback instance, allowing subclasses to listen to or override specific 21 * window messages. 22 */ 23 class WindowCallbackWrapper implements Window.Callback { 24 private final Window.Callback mCallback; 25 WindowCallbackWrapper(Window.Callback callback)26 public WindowCallbackWrapper(Window.Callback callback) { 27 mCallback = callback; 28 } 29 30 @Override dispatchGenericMotionEvent(MotionEvent event)31 public boolean dispatchGenericMotionEvent(MotionEvent event) { 32 return mCallback.dispatchGenericMotionEvent(event); 33 } 34 35 @Override dispatchKeyEvent(KeyEvent event)36 public boolean dispatchKeyEvent(KeyEvent event) { 37 return mCallback.dispatchKeyEvent(event); 38 } 39 40 @Override dispatchKeyShortcutEvent(KeyEvent event)41 public boolean dispatchKeyShortcutEvent(KeyEvent event) { 42 return mCallback.dispatchKeyShortcutEvent(event); 43 } 44 45 @Override dispatchPopulateAccessibilityEvent(AccessibilityEvent event)46 public boolean dispatchPopulateAccessibilityEvent(AccessibilityEvent event) { 47 return mCallback.dispatchPopulateAccessibilityEvent(event); 48 } 49 50 @Override dispatchTouchEvent(MotionEvent event)51 public boolean dispatchTouchEvent(MotionEvent event) { 52 return mCallback.dispatchTouchEvent(event); 53 } 54 55 @Override dispatchTrackballEvent(MotionEvent event)56 public boolean dispatchTrackballEvent(MotionEvent event) { 57 return mCallback.dispatchTrackballEvent(event); 58 } 59 60 @Override onActionModeFinished(ActionMode mode)61 public void onActionModeFinished(ActionMode mode) { 62 mCallback.onActionModeFinished(mode); 63 } 64 65 @Override onActionModeStarted(ActionMode mode)66 public void onActionModeStarted(ActionMode mode) { 67 mCallback.onActionModeStarted(mode); 68 } 69 70 @Override onAttachedToWindow()71 public void onAttachedToWindow() { 72 mCallback.onAttachedToWindow(); 73 } 74 75 @Override onContentChanged()76 public void onContentChanged() { 77 mCallback.onContentChanged(); 78 } 79 80 @Override onCreatePanelMenu(int featureId, Menu menu)81 public boolean onCreatePanelMenu(int featureId, Menu menu) { 82 return mCallback.onCreatePanelMenu(featureId, menu); 83 } 84 85 @Override onCreatePanelView(int featureId)86 public View onCreatePanelView(int featureId) { 87 return mCallback.onCreatePanelView(featureId); 88 } 89 90 @Override 91 @SuppressLint("MissingSuperCall") onDetachedFromWindow()92 public void onDetachedFromWindow() { 93 mCallback.onDetachedFromWindow(); 94 } 95 96 @Override onMenuItemSelected(int featureId, MenuItem item)97 public boolean onMenuItemSelected(int featureId, MenuItem item) { 98 return mCallback.onMenuItemSelected(featureId, item); 99 } 100 101 @Override onMenuOpened(int featureId, Menu menu)102 public boolean onMenuOpened(int featureId, Menu menu) { 103 return mCallback.onMenuOpened(featureId, menu); 104 } 105 106 @Override onPanelClosed(int featureId, Menu menu)107 public void onPanelClosed(int featureId, Menu menu) { 108 mCallback.onPanelClosed(featureId, menu); 109 } 110 111 @Override onPreparePanel(int featureId, View view, Menu menu)112 public boolean onPreparePanel(int featureId, View view, Menu menu) { 113 return mCallback.onPreparePanel(featureId, view, menu); 114 } 115 116 @Override onSearchRequested()117 public boolean onSearchRequested() { 118 return mCallback.onSearchRequested(); 119 } 120 121 @Override onWindowAttributesChanged(LayoutParams attrs)122 public void onWindowAttributesChanged(LayoutParams attrs) { 123 mCallback.onWindowAttributesChanged(attrs); 124 } 125 126 @Override onWindowFocusChanged(boolean hasFocus)127 public void onWindowFocusChanged(boolean hasFocus) { 128 mCallback.onWindowFocusChanged(hasFocus); 129 } 130 131 @Override onWindowStartingActionMode(Callback callback)132 public ActionMode onWindowStartingActionMode(Callback callback) { 133 return mCallback.onWindowStartingActionMode(callback); 134 } 135 onWindowDismissed()136 public void onWindowDismissed() { 137 // TODO(benm): implement me. 138 } 139 140 } 141