1 /* 2 * Copyright (C) 2015 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 package android.support.car.input; 17 18 import android.widget.EditText; 19 20 /** 21 * Manages use of the in-car IME. All methods should only be called on the main thread. 22 * Instances should be obtained by calling {@link android.support.car.app.CarActivity#getInputManager()}. 23 */ 24 public abstract class CarInputManager { 25 /** 26 * Starts input on the requested {@link android.widget.EditText}, showing the IME. 27 * If IME input is already occurring for another view, this call stops input on the previous 28 * view and starts input on the new view. 29 * 30 * This method must only be called from the UI thread. Calling this method from a stopped 31 * activity is an illegal operation. 32 */ 33 abstract public void startInput(EditText view); 34 35 /** 36 * Stops input, hiding the IME. This method fails silently if the calling application didn't 37 * request input and isn't the active IME. 38 * 39 * This function must only be called from the UI thread. 40 */ 41 abstract public void stopInput(); 42 43 /** 44 * Returns {@code true} while the InputManager is valid. The InputManager is valid as long as 45 * the {@link android.support.car.app.CarActivity} from which it was obtained has 46 * been created and not destroyed. 47 */ 48 abstract public boolean isValid(); 49 50 /** 51 * Returns {@code true} if this InputManager is valid and the IME is active. 52 */ 53 abstract public boolean isInputActive(); 54 55 /** 56 * Returns {@code true} if IME is active on the given {@link android.widget.EditText}. 57 */ 58 abstract public boolean isCurrentCarEditable(EditText view); 59 60 } 61