blob: 0704a54731998b99c741c8eb3f3c28773e25cbf3 [file] [log] [blame]
Yao Chen5e36c882015-11-06 16:13:23 -08001/*
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 */
16package android.support.car.input;
17
Yao Chen70f6a632016-02-10 15:23:09 -080018import android.widget.EditText;
19
Yao Chen5e36c882015-11-06 16:13:23 -080020/**
21 * Manages use of the in-car IME. All methods should only be called on the main thread.
Jason Tholstrup9aaf8b92016-08-04 14:25:16 -070022 * Instances should be obtained by calling
23 * {@link android.support.car.app.CarActivity#getInputManager()}.
24 * @hide
Yao Chen5e36c882015-11-06 16:13:23 -080025 */
26public abstract class CarInputManager {
27 /**
Yao Chen70f6a632016-02-10 15:23:09 -080028 * Starts input on the requested {@link android.widget.EditText}, showing the IME.
Yao Chen5e36c882015-11-06 16:13:23 -080029 * 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 Chen70f6a632016-02-10 15:23:09 -080035 abstract public void startInput(EditText view);
Yao Chen5e36c882015-11-06 16:13:23 -080036
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 Chen70f6a632016-02-10 15:23:09 -080058 * Returns {@code true} if IME is active on the given {@link android.widget.EditText}.
Yao Chen5e36c882015-11-06 16:13:23 -080059 */
Yao Chen70f6a632016-02-10 15:23:09 -080060 abstract public boolean isCurrentCarEditable(EditText view);
Yao Chen5e36c882015-11-06 16:13:23 -080061
62}