lumark | d85e158 | 2019-12-29 20:20:41 +0800 | [diff] [blame] | 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, |
Joshua Tsuji | 53f6e83 | 2020-06-21 22:21:15 -0400 | [diff] [blame] | 49 | SoftInputShowHideReason.HIDE_RECENTS_ANIMATION, |
| 50 | SoftInputShowHideReason.HIDE_BUBBLES}) |
lumark | d85e158 | 2019-12-29 20:20:41 +0800 | [diff] [blame] | 51 | public @interface SoftInputShowHideReason { |
| 52 | /** Show soft input by {@link android.view.inputmethod.InputMethodManager#showSoftInput}. */ |
| 53 | int SHOW_SOFT_INPUT = 0; |
| 54 | |
| 55 | /** Show soft input when {@code InputMethodManagerService#attachNewInputLocked} called. */ |
| 56 | int ATTACH_NEW_INPUT = 1; |
| 57 | |
| 58 | /** Show soft input by {@code InputMethodManagerService#showMySoftInput}. */ |
| 59 | int SHOW_MY_SOFT_INPUT = 2; |
| 60 | |
| 61 | /** |
| 62 | * Hide soft input by |
| 63 | * {@link android.view.inputmethod.InputMethodManager#hideSoftInputFromWindow}. |
| 64 | */ |
| 65 | int HIDE_SOFT_INPUT = 3; |
| 66 | |
| 67 | /** Hide soft input by {@code InputMethodManagerService#hideMySoftInput}. */ |
| 68 | int HIDE_MY_SOFT_INPUT = 4; |
| 69 | |
| 70 | /** |
| 71 | * Show soft input when navigated forward to the window (with |
| 72 | * {@link LayoutParams#SOFT_INPUT_IS_FORWARD_NAVIGATION}} which the focused view is text |
| 73 | * editor and system will auto-show the IME when the window can resize or running on a large |
| 74 | * screen. |
| 75 | */ |
| 76 | int SHOW_AUTO_EDITOR_FORWARD_NAV = 5; |
| 77 | |
| 78 | /** |
| 79 | * Show soft input when navigated forward to the window with |
| 80 | * {@link LayoutParams#SOFT_INPUT_IS_FORWARD_NAVIGATION} and |
| 81 | * {@link LayoutParams#SOFT_INPUT_STATE_VISIBLE}. |
| 82 | */ |
| 83 | int SHOW_STATE_VISIBLE_FORWARD_NAV = 6; |
| 84 | |
| 85 | /** |
| 86 | * Show soft input when the window with {@link LayoutParams#SOFT_INPUT_STATE_ALWAYS_VISIBLE}. |
| 87 | */ |
| 88 | int SHOW_STATE_ALWAYS_VISIBLE = 7; |
| 89 | |
| 90 | /** |
| 91 | * Show soft input during {@code InputMethodManagerService} receive changes from |
| 92 | * {@code SettingsProvider}. |
| 93 | */ |
| 94 | int SHOW_SETTINGS_ON_CHANGE = 8; |
| 95 | |
| 96 | /** Hide soft input during switching user. */ |
| 97 | int HIDE_SWITCH_USER = 9; |
| 98 | |
| 99 | /** Hide soft input when the user is invalid. */ |
| 100 | int HIDE_INVALID_USER = 10; |
| 101 | |
| 102 | /** |
| 103 | * Hide soft input when the window with {@link LayoutParams#SOFT_INPUT_STATE_UNSPECIFIED} which |
| 104 | * the focused view is not text editor. |
| 105 | */ |
| 106 | int HIDE_UNSPECIFIED_WINDOW = 11; |
| 107 | |
| 108 | /** |
| 109 | * Hide soft input when navigated forward to the window with |
| 110 | * {@link LayoutParams#SOFT_INPUT_IS_FORWARD_NAVIGATION} and |
| 111 | * {@link LayoutParams#SOFT_INPUT_STATE_HIDDEN}. |
| 112 | */ |
| 113 | int HIDE_STATE_HIDDEN_FORWARD_NAV = 12; |
| 114 | |
| 115 | /** |
| 116 | * Hide soft input when the window with {@link LayoutParams#SOFT_INPUT_STATE_ALWAYS_HIDDEN}. |
| 117 | */ |
| 118 | int HIDE_ALWAYS_HIDDEN_STATE = 13; |
| 119 | |
| 120 | /** Hide soft input when "adb shell ime <command>" called. */ |
| 121 | int HIDE_RESET_SHELL_COMMAND = 14; |
| 122 | |
| 123 | /** |
| 124 | * Hide soft input during {@code InputMethodManagerService} receive changes from |
| 125 | * {@code SettingsProvider}. |
| 126 | */ |
| 127 | int HIDE_SETTINGS_ON_CHANGE = 15; |
| 128 | |
| 129 | /** |
| 130 | * Hide soft input from {@link com.android.server.policy.PhoneWindowManager} when setting |
| 131 | * {@link com.android.internal.R.integer#config_shortPressOnPowerBehavior} in config.xml as |
| 132 | * dismiss IME. |
| 133 | */ |
| 134 | int HIDE_POWER_BUTTON_GO_HOME = 16; |
| 135 | |
| 136 | /** Hide soft input when attaching docked stack. */ |
| 137 | int HIDE_DOCKED_STACK_ATTACHED = 17; |
| 138 | |
| 139 | /** |
| 140 | * Hide soft input when {@link com.android.server.wm.RecentsAnimationController} starts |
| 141 | * intercept touch from app window. |
| 142 | */ |
| 143 | int HIDE_RECENTS_ANIMATION = 18; |
Joshua Tsuji | 53f6e83 | 2020-06-21 22:21:15 -0400 | [diff] [blame] | 144 | |
| 145 | /** |
| 146 | * Hide soft input when {@link com.android.systemui.bubbles.BubbleController} is expanding, |
| 147 | * switching, or collapsing Bubbles. |
| 148 | */ |
| 149 | int HIDE_BUBBLES = 19; |
lumark | d85e158 | 2019-12-29 20:20:41 +0800 | [diff] [blame] | 150 | } |