summaryrefslogtreecommitdiff
path: root/core/java/com/android/internal/inputmethod/SoftInputShowHideReason.java
blob: 97ad5cb4663c5fbccdf87f52875a4a1906fbcf57 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
/*
 * Copyright (C) 2020 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package com.android.internal.inputmethod;

import static java.lang.annotation.RetentionPolicy.SOURCE;

import android.annotation.IntDef;
import android.os.IBinder;
import android.view.WindowManager;
import android.view.WindowManager.LayoutParams;
import android.view.inputmethod.EditorInfo;
import android.view.inputmethod.InputMethodManager;

import java.lang.annotation.Retention;

/**
 * Describes the reason why Soft input window visible / hidden.
 */
@Retention(SOURCE)
@IntDef(value = {
        SoftInputShowHideReason.SHOW_SOFT_INPUT,
        SoftInputShowHideReason.ATTACH_NEW_INPUT,
        SoftInputShowHideReason.SHOW_SOFT_INPUT_FROM_IME,
        SoftInputShowHideReason.HIDE_SOFT_INPUT,
        SoftInputShowHideReason.HIDE_SOFT_INPUT_FROM_IME,
        SoftInputShowHideReason.SHOW_AUTO_EDITOR_FORWARD_NAV,
        SoftInputShowHideReason.SHOW_STATE_VISIBLE_FORWARD_NAV,
        SoftInputShowHideReason.SHOW_STATE_ALWAYS_VISIBLE,
        SoftInputShowHideReason.SHOW_SETTINGS_ON_CHANGE,
        SoftInputShowHideReason.HIDE_SWITCH_USER,
        SoftInputShowHideReason.HIDE_INVALID_USER,
        SoftInputShowHideReason.HIDE_UNSPECIFIED_WINDOW,
        SoftInputShowHideReason.HIDE_STATE_HIDDEN_FORWARD_NAV,
        SoftInputShowHideReason.HIDE_ALWAYS_HIDDEN_STATE,
        SoftInputShowHideReason.HIDE_RESET_SHELL_COMMAND,
        SoftInputShowHideReason.HIDE_SETTINGS_ON_CHANGE,
        SoftInputShowHideReason.HIDE_POWER_BUTTON_GO_HOME,
        SoftInputShowHideReason.HIDE_DOCKED_STACK_ATTACHED,
        SoftInputShowHideReason.HIDE_RECENTS_ANIMATION,
        SoftInputShowHideReason.HIDE_BUBBLES,
        SoftInputShowHideReason.HIDE_SAME_WINDOW_FOCUSED_WITHOUT_EDITOR,
        SoftInputShowHideReason.HIDE_REMOVE_CLIENT,
        SoftInputShowHideReason.SHOW_RESTORE_IME_VISIBILITY,
        SoftInputShowHideReason.SHOW_TOGGLE_SOFT_INPUT,
        SoftInputShowHideReason.HIDE_TOGGLE_SOFT_INPUT,
        SoftInputShowHideReason.SHOW_SOFT_INPUT_BY_INSETS_API,
        SoftInputShowHideReason.HIDE_DISPLAY_IME_POLICY_HIDE,
        SoftInputShowHideReason.HIDE_SOFT_INPUT_BY_INSETS_API,
        SoftInputShowHideReason.HIDE_SOFT_INPUT_BY_BACK_KEY,
        SoftInputShowHideReason.HIDE_SOFT_INPUT_IME_TOGGLE_SOFT_INPUT,
        SoftInputShowHideReason.HIDE_SOFT_INPUT_EXTRACT_INPUT_CHANGED,
        SoftInputShowHideReason.HIDE_SOFT_INPUT_IMM_DEPRECATION})
public @interface SoftInputShowHideReason {
    /** Show soft input by {@link android.view.inputmethod.InputMethodManager#showSoftInput}. */
    int SHOW_SOFT_INPUT = 0;

    /** Show soft input when {@code InputMethodManagerService#attachNewInputLocked} called. */
    int ATTACH_NEW_INPUT = 1;

    /** Show soft input by {@code InputMethodManagerService#showMySoftInput}. This is triggered when
     *  the IME process try to show the keyboard.
     *
     * @see android.inputmethodservice.InputMethodService#requestShowSelf(int)
     */
    int SHOW_SOFT_INPUT_FROM_IME = 2;

    /**
     * Hide soft input by
     * {@link android.view.inputmethod.InputMethodManager#hideSoftInputFromWindow}.
     */
    int HIDE_SOFT_INPUT = 3;

    /**
     * Hide soft input by
     * {@link android.inputmethodservice.InputMethodService#requestHideSelf(int)}.
     */
    int HIDE_SOFT_INPUT_FROM_IME = 4;

    /**
     * Show soft input when navigated forward to the window (with
     * {@link LayoutParams#SOFT_INPUT_IS_FORWARD_NAVIGATION}} which the focused view is text
     * editor and system will auto-show the IME when the window can resize or running on a large
     * screen.
     */
    int SHOW_AUTO_EDITOR_FORWARD_NAV = 5;

    /**
     * Show soft input when navigated forward to the window with
     * {@link LayoutParams#SOFT_INPUT_IS_FORWARD_NAVIGATION} and
     * {@link LayoutParams#SOFT_INPUT_STATE_VISIBLE}.
     */
    int SHOW_STATE_VISIBLE_FORWARD_NAV = 6;

    /**
     * Show soft input when the window with {@link LayoutParams#SOFT_INPUT_STATE_ALWAYS_VISIBLE}.
     */
    int SHOW_STATE_ALWAYS_VISIBLE = 7;

    /**
     * Show soft input during {@code InputMethodManagerService} receive changes from
     * {@code SettingsProvider}.
     */
    int SHOW_SETTINGS_ON_CHANGE = 8;

    /** Hide soft input during switching user. */
    int HIDE_SWITCH_USER = 9;

    /** Hide soft input when the user is invalid. */
    int HIDE_INVALID_USER = 10;

    /**
     * Hide soft input when the window with {@link LayoutParams#SOFT_INPUT_STATE_UNSPECIFIED} which
     * the focused view is not text editor.
     */
    int HIDE_UNSPECIFIED_WINDOW = 11;

    /**
     * Hide soft input when navigated forward to the window with
     * {@link LayoutParams#SOFT_INPUT_IS_FORWARD_NAVIGATION} and
     * {@link LayoutParams#SOFT_INPUT_STATE_HIDDEN}.
     */
    int HIDE_STATE_HIDDEN_FORWARD_NAV = 12;

    /**
     * Hide soft input when the window with {@link LayoutParams#SOFT_INPUT_STATE_ALWAYS_HIDDEN}.
     */
    int HIDE_ALWAYS_HIDDEN_STATE = 13;

    /** Hide soft input when "adb shell ime <command>" called. */
    int HIDE_RESET_SHELL_COMMAND = 14;

    /**
     * Hide soft input during {@code InputMethodManagerService} receive changes from
     * {@code SettingsProvider}.
     */
    int HIDE_SETTINGS_ON_CHANGE = 15;

    /**
     * Hide soft input from {@link com.android.server.policy.PhoneWindowManager} when setting
     * {@link com.android.internal.R.integer#config_shortPressOnPowerBehavior} in config.xml as
     * dismiss IME.
     */
    int HIDE_POWER_BUTTON_GO_HOME = 16;

    /** Hide soft input when attaching docked stack. */
    int HIDE_DOCKED_STACK_ATTACHED = 17;

    /**
     * Hide soft input when {@link com.android.server.wm.RecentsAnimationController} starts
     * intercept touch from app window.
     */
    int HIDE_RECENTS_ANIMATION = 18;

    /**
     * Hide soft input when {@link com.android.wm.shell.bubbles.BubbleController} is expanding,
     * switching, or collapsing Bubbles.
     */
    int HIDE_BUBBLES = 19;

    /**
     * Hide soft input when focusing the same window (e.g. screen turned-off and turn-on) which no
     * valid focused editor.
     *
     * Note: From Android R, the window focus change callback is processed by InputDispatcher,
     * some focus behavior changes (e.g. There are an activity with a dialog window, after
     * screen turned-off and turned-on, before Android R the window focus sequence would be
     * the activity first and then the dialog focused, however, in R the focus sequence would be
     * only the dialog focused as it's the latest window with input focus) makes we need to hide
     * soft-input when the same window focused again to align with the same behavior prior to R.
     */
    int HIDE_SAME_WINDOW_FOCUSED_WITHOUT_EDITOR = 20;

    /**
     * Hide soft input when a {@link com.android.internal.view.IInputMethodClient} is removed.
     */
    int HIDE_REMOVE_CLIENT = 21;

    /**
     * Show soft input when the system invoking
     * {@link com.android.server.wm.WindowManagerInternal#shouldRestoreImeVisibility}.
     */
    int SHOW_RESTORE_IME_VISIBILITY = 22;

    /**
     * Show soft input by
     * {@link android.view.inputmethod.InputMethodManager#toggleSoftInput(int, int)};
     */
    int SHOW_TOGGLE_SOFT_INPUT = 23;

    /**
     * Hide soft input by
     * {@link android.view.inputmethod.InputMethodManager#toggleSoftInput(int, int)};
     */
    int HIDE_TOGGLE_SOFT_INPUT = 24;

    /**
     * Show soft input by
     * {@link android.view.InsetsController#show(int)};
     */
    int SHOW_SOFT_INPUT_BY_INSETS_API = 25;

    /**
     * Hide soft input if Ime policy has been set to {@link WindowManager#DISPLAY_IME_POLICY_HIDE}.
     * See also {@code InputMethodManagerService#mImeHiddenByDisplayPolicy}.
     */
    int HIDE_DISPLAY_IME_POLICY_HIDE = 26;

    /**
     * Hide soft input by {@link android.view.InsetsController#hide(int)}.
     */
    int HIDE_SOFT_INPUT_BY_INSETS_API = 27;

    /**
     * Hide soft input by {@link android.inputmethodservice.InputMethodService#handleBack(boolean)}.
     */
    int HIDE_SOFT_INPUT_BY_BACK_KEY = 28;

    /**
     * Hide soft input by
     * {@link android.inputmethodservice.InputMethodService#onToggleSoftInput(int, int)}.
     */
    int HIDE_SOFT_INPUT_IME_TOGGLE_SOFT_INPUT = 29;

    /**
     * Hide soft input by
     * {@link android.inputmethodservice.InputMethodService#onExtractingInputChanged(EditorInfo)})}.
     */
    int HIDE_SOFT_INPUT_EXTRACT_INPUT_CHANGED = 30;

    /**
     * Hide soft input by the deprecated
     * {@link InputMethodManager#hideSoftInputFromInputMethod(IBinder, int)}.
     */
    int HIDE_SOFT_INPUT_IMM_DEPRECATION = 31;
}