1 /* 2 * Copyright (C) 2014 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except 5 * in compliance with the License. You may obtain a copy of the License at 6 * 7 * http://www.apache.org/licenses/LICENSE-2.0 8 * 9 * Unless required by applicable law or agreed to in writing, software distributed under the License 10 * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 11 * or implied. See the License for the specific language governing permissions and limitations under 12 * the License. 13 */ 14 package android.support.v17.leanback.widget; 15 16 import android.widget.EditText; 17 import android.view.KeyEvent; 18 19 /** 20 * Interface for an EditText subclass that can delegate calls to onKeyPreIme up to a registered 21 * listener. 22 * <p> 23 * Used in editable actions within {@link android.support.v17.leanback.app.GuidedStepFragment} to 24 * allow for custom back key handling. Specifically, this is used to implement the behavior that 25 * dismissing the IME also clears edit text focus. Clients who need to supply custom layouts for 26 * {@link GuidedActionsStylist} with their own EditText classes should satisfy this interface in 27 * order to inherit this behavior. 28 */ 29 public interface ImeKeyMonitor { 30 31 /** 32 * Listener interface for key events intercepted pre-IME by edit text objects. 33 */ 34 public interface ImeKeyListener { 35 /** 36 * Callback invoked from EditText's onKeyPreIme method override. Returning true tells the 37 * caller that the key event is handled and should not be propagated. 38 */ onKeyPreIme(EditText editText, int keyCode, KeyEvent event)39 public abstract boolean onKeyPreIme(EditText editText, int keyCode, KeyEvent event); 40 } 41 42 /** 43 * Set the listener for this edit text object. The listener's onKeyPreIme method will be 44 * invoked from the host edit text's onKeyPreIme method. 45 */ setImeKeyListener(ImeKeyListener listener)46 public void setImeKeyListener(ImeKeyListener listener); 47 } 48