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