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 17 package com.android.internal.view; 18 19 import android.annotation.IntDef; 20 21 import java.lang.annotation.Retention; 22 23 import static java.lang.annotation.RetentionPolicy.SOURCE; 24 25 public final class InputMethodClient { 26 public static final int START_INPUT_REASON_UNSPECIFIED = 0; 27 public static final int START_INPUT_REASON_WINDOW_FOCUS_GAIN = 1; 28 public static final int START_INPUT_REASON_WINDOW_FOCUS_GAIN_REPORT_ONLY = 2; 29 public static final int START_INPUT_REASON_APP_CALLED_RESTART_INPUT_API = 3; 30 public static final int START_INPUT_REASON_CHECK_FOCUS = 4; 31 public static final int START_INPUT_REASON_BOUND_TO_IMMS = 5; 32 public static final int START_INPUT_REASON_UNBOUND_FROM_IMMS = 6; 33 public static final int START_INPUT_REASON_ACTIVATED_BY_IMMS = 7; 34 public static final int START_INPUT_REASON_DEACTIVATED_BY_IMMS = 8; 35 36 @Retention(SOURCE) 37 @IntDef({START_INPUT_REASON_UNSPECIFIED, START_INPUT_REASON_WINDOW_FOCUS_GAIN, 38 START_INPUT_REASON_WINDOW_FOCUS_GAIN_REPORT_ONLY, 39 START_INPUT_REASON_APP_CALLED_RESTART_INPUT_API, START_INPUT_REASON_CHECK_FOCUS, 40 START_INPUT_REASON_BOUND_TO_IMMS, START_INPUT_REASON_ACTIVATED_BY_IMMS, 41 START_INPUT_REASON_DEACTIVATED_BY_IMMS}) 42 public @interface StartInputReason {} 43 getStartInputReason(@tartInputReason final int reason)44 public static String getStartInputReason(@StartInputReason final int reason) { 45 switch (reason) { 46 case START_INPUT_REASON_UNSPECIFIED: 47 return "UNSPECIFIED"; 48 case START_INPUT_REASON_WINDOW_FOCUS_GAIN: 49 return "WINDOW_FOCUS_GAIN"; 50 case START_INPUT_REASON_WINDOW_FOCUS_GAIN_REPORT_ONLY: 51 return "WINDOW_FOCUS_GAIN_REPORT_ONLY"; 52 case START_INPUT_REASON_APP_CALLED_RESTART_INPUT_API: 53 return "APP_CALLED_RESTART_INPUT_API"; 54 case START_INPUT_REASON_CHECK_FOCUS: 55 return "CHECK_FOCUS"; 56 case START_INPUT_REASON_BOUND_TO_IMMS: 57 return "BOUND_TO_IMMS"; 58 case START_INPUT_REASON_UNBOUND_FROM_IMMS: 59 return "UNBOUND_FROM_IMMS"; 60 case START_INPUT_REASON_ACTIVATED_BY_IMMS: 61 return "ACTIVATED_BY_IMMS"; 62 case START_INPUT_REASON_DEACTIVATED_BY_IMMS: 63 return "DEACTIVATED_BY_IMMS"; 64 default: 65 return "Unknown=" + reason; 66 } 67 } 68 69 public static final int UNBIND_REASON_UNSPECIFIED = 0; 70 public static final int UNBIND_REASON_SWITCH_CLIENT = 1; 71 public static final int UNBIND_REASON_SWITCH_IME = 2; 72 public static final int UNBIND_REASON_DISCONNECT_IME = 3; 73 public static final int UNBIND_REASON_NO_IME = 4; 74 public static final int UNBIND_REASON_SWITCH_IME_FAILED = 5; 75 public static final int UNBIND_REASON_RESET_IME = 6; 76 77 @Retention(SOURCE) 78 @IntDef({UNBIND_REASON_UNSPECIFIED, UNBIND_REASON_SWITCH_CLIENT, UNBIND_REASON_SWITCH_IME, 79 UNBIND_REASON_DISCONNECT_IME, UNBIND_REASON_NO_IME, UNBIND_REASON_SWITCH_IME_FAILED, 80 UNBIND_REASON_RESET_IME}) 81 public @interface UnbindReason {} 82 getUnbindReason(@nbindReason final int reason)83 public static String getUnbindReason(@UnbindReason final int reason) { 84 switch (reason) { 85 case UNBIND_REASON_UNSPECIFIED: 86 return "UNSPECIFIED"; 87 case UNBIND_REASON_SWITCH_CLIENT: 88 return "SWITCH_CLIENT"; 89 case UNBIND_REASON_SWITCH_IME: 90 return "SWITCH_IME"; 91 case UNBIND_REASON_DISCONNECT_IME: 92 return "DISCONNECT_IME"; 93 case UNBIND_REASON_NO_IME: 94 return "NO_IME"; 95 case UNBIND_REASON_SWITCH_IME_FAILED: 96 return "SWITCH_IME_FAILED"; 97 case UNBIND_REASON_RESET_IME: 98 return "RESET_IME"; 99 default: 100 return "Unknown=" + reason; 101 } 102 } 103 } 104