1 /* 2 * Copyright (C) 2020 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.inputmethod; 18 19 import static java.lang.annotation.RetentionPolicy.SOURCE; 20 21 import android.annotation.IntDef; 22 import android.view.WindowManager.LayoutParams; 23 24 import java.lang.annotation.Retention; 25 26 /** 27 * Describes the reason why Soft input window visible / hidden. 28 */ 29 @Retention(SOURCE) 30 @IntDef(value = { 31 SoftInputShowHideReason.SHOW_SOFT_INPUT, 32 SoftInputShowHideReason.ATTACH_NEW_INPUT, 33 SoftInputShowHideReason.SHOW_MY_SOFT_INPUT, 34 SoftInputShowHideReason.HIDE_SOFT_INPUT, 35 SoftInputShowHideReason.HIDE_MY_SOFT_INPUT, 36 SoftInputShowHideReason.SHOW_AUTO_EDITOR_FORWARD_NAV, 37 SoftInputShowHideReason.SHOW_STATE_VISIBLE_FORWARD_NAV, 38 SoftInputShowHideReason.SHOW_STATE_ALWAYS_VISIBLE, 39 SoftInputShowHideReason.SHOW_SETTINGS_ON_CHANGE, 40 SoftInputShowHideReason.HIDE_SWITCH_USER, 41 SoftInputShowHideReason.HIDE_INVALID_USER, 42 SoftInputShowHideReason.HIDE_UNSPECIFIED_WINDOW, 43 SoftInputShowHideReason.HIDE_STATE_HIDDEN_FORWARD_NAV, 44 SoftInputShowHideReason.HIDE_ALWAYS_HIDDEN_STATE, 45 SoftInputShowHideReason.HIDE_RESET_SHELL_COMMAND, 46 SoftInputShowHideReason.HIDE_SETTINGS_ON_CHANGE, 47 SoftInputShowHideReason.HIDE_POWER_BUTTON_GO_HOME, 48 SoftInputShowHideReason.HIDE_DOCKED_STACK_ATTACHED, 49 SoftInputShowHideReason.HIDE_RECENTS_ANIMATION, 50 SoftInputShowHideReason.HIDE_BUBBLES, 51 SoftInputShowHideReason.HIDE_SAME_WINDOW_FOCUSED_WITHOUT_EDITOR, 52 SoftInputShowHideReason.HIDE_REMOVE_CLIENT, 53 SoftInputShowHideReason.SHOW_RESTORE_IME_VISIBILITY, 54 SoftInputShowHideReason.SHOW_TOGGLE_SOFT_INPUT, 55 SoftInputShowHideReason.HIDE_TOGGLE_SOFT_INPUT, 56 SoftInputShowHideReason.SHOW_SOFT_INPUT_BY_INSETS_API}) 57 public @interface SoftInputShowHideReason { 58 /** Show soft input by {@link android.view.inputmethod.InputMethodManager#showSoftInput}. */ 59 int SHOW_SOFT_INPUT = 0; 60 61 /** Show soft input when {@code InputMethodManagerService#attachNewInputLocked} called. */ 62 int ATTACH_NEW_INPUT = 1; 63 64 /** Show soft input by {@code InputMethodManagerService#showMySoftInput}. */ 65 int SHOW_MY_SOFT_INPUT = 2; 66 67 /** 68 * Hide soft input by 69 * {@link android.view.inputmethod.InputMethodManager#hideSoftInputFromWindow}. 70 */ 71 int HIDE_SOFT_INPUT = 3; 72 73 /** Hide soft input by {@code InputMethodManagerService#hideMySoftInput}. */ 74 int HIDE_MY_SOFT_INPUT = 4; 75 76 /** 77 * Show soft input when navigated forward to the window (with 78 * {@link LayoutParams#SOFT_INPUT_IS_FORWARD_NAVIGATION}} which the focused view is text 79 * editor and system will auto-show the IME when the window can resize or running on a large 80 * screen. 81 */ 82 int SHOW_AUTO_EDITOR_FORWARD_NAV = 5; 83 84 /** 85 * Show soft input when navigated forward to the window with 86 * {@link LayoutParams#SOFT_INPUT_IS_FORWARD_NAVIGATION} and 87 * {@link LayoutParams#SOFT_INPUT_STATE_VISIBLE}. 88 */ 89 int SHOW_STATE_VISIBLE_FORWARD_NAV = 6; 90 91 /** 92 * Show soft input when the window with {@link LayoutParams#SOFT_INPUT_STATE_ALWAYS_VISIBLE}. 93 */ 94 int SHOW_STATE_ALWAYS_VISIBLE = 7; 95 96 /** 97 * Show soft input during {@code InputMethodManagerService} receive changes from 98 * {@code SettingsProvider}. 99 */ 100 int SHOW_SETTINGS_ON_CHANGE = 8; 101 102 /** Hide soft input during switching user. */ 103 int HIDE_SWITCH_USER = 9; 104 105 /** Hide soft input when the user is invalid. */ 106 int HIDE_INVALID_USER = 10; 107 108 /** 109 * Hide soft input when the window with {@link LayoutParams#SOFT_INPUT_STATE_UNSPECIFIED} which 110 * the focused view is not text editor. 111 */ 112 int HIDE_UNSPECIFIED_WINDOW = 11; 113 114 /** 115 * Hide soft input when navigated forward to the window with 116 * {@link LayoutParams#SOFT_INPUT_IS_FORWARD_NAVIGATION} and 117 * {@link LayoutParams#SOFT_INPUT_STATE_HIDDEN}. 118 */ 119 int HIDE_STATE_HIDDEN_FORWARD_NAV = 12; 120 121 /** 122 * Hide soft input when the window with {@link LayoutParams#SOFT_INPUT_STATE_ALWAYS_HIDDEN}. 123 */ 124 int HIDE_ALWAYS_HIDDEN_STATE = 13; 125 126 /** Hide soft input when "adb shell ime <command>" called. */ 127 int HIDE_RESET_SHELL_COMMAND = 14; 128 129 /** 130 * Hide soft input during {@code InputMethodManagerService} receive changes from 131 * {@code SettingsProvider}. 132 */ 133 int HIDE_SETTINGS_ON_CHANGE = 15; 134 135 /** 136 * Hide soft input from {@link com.android.server.policy.PhoneWindowManager} when setting 137 * {@link com.android.internal.R.integer#config_shortPressOnPowerBehavior} in config.xml as 138 * dismiss IME. 139 */ 140 int HIDE_POWER_BUTTON_GO_HOME = 16; 141 142 /** Hide soft input when attaching docked stack. */ 143 int HIDE_DOCKED_STACK_ATTACHED = 17; 144 145 /** 146 * Hide soft input when {@link com.android.server.wm.RecentsAnimationController} starts 147 * intercept touch from app window. 148 */ 149 int HIDE_RECENTS_ANIMATION = 18; 150 151 /** 152 * Hide soft input when {@link com.android.wm.shell.bubbles.BubbleController} is expanding, 153 * switching, or collapsing Bubbles. 154 */ 155 int HIDE_BUBBLES = 19; 156 157 /** 158 * Hide soft input when focusing the same window (e.g. screen turned-off and turn-on) which no 159 * valid focused editor. 160 * 161 * Note: From Android R, the window focus change callback is processed by InputDispatcher, 162 * some focus behavior changes (e.g. There are an activity with a dialog window, after 163 * screen turned-off and turned-on, before Android R the window focus sequence would be 164 * the activity first and then the dialog focused, however, in R the focus sequence would be 165 * only the dialog focused as it's the latest window with input focus) makes we need to hide 166 * soft-input when the same window focused again to align with the same behavior prior to R. 167 */ 168 int HIDE_SAME_WINDOW_FOCUSED_WITHOUT_EDITOR = 20; 169 170 /** 171 * Hide soft input when a {@link com.android.internal.view.IInputMethodClient} is removed. 172 */ 173 int HIDE_REMOVE_CLIENT = 21; 174 175 /** 176 * Show soft input when the system invoking 177 * {@link com.android.server.wm.WindowManagerInternal#shouldRestoreImeVisibility}. 178 */ 179 int SHOW_RESTORE_IME_VISIBILITY = 22; 180 181 /** 182 * Show soft input by 183 * {@link android.view.inputmethod.InputMethodManager#toggleSoftInput(int, int)}; 184 */ 185 int SHOW_TOGGLE_SOFT_INPUT = 23; 186 187 /** 188 * Hide soft input by 189 * {@link android.view.inputmethod.InputMethodManager#toggleSoftInput(int, int)}; 190 */ 191 int HIDE_TOGGLE_SOFT_INPUT = 24; 192 193 /** 194 * Show soft input by 195 * {@link android.view.InsetsController#show(int)}; 196 */ 197 int SHOW_SOFT_INPUT_BY_INSETS_API = 25; 198 } 199