• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2019 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.server.wm;
18 
19 import android.inputmethodservice.InputMethodService;
20 import android.view.InsetsState;
21 import android.view.WindowInsets.Type.InsetsType;
22 
23 /**
24  * Generalization of an object that can control insets state.
25  */
26 interface InsetsControlTarget {
27 
28     /**
29      * Notifies the control target that the insets control has changed.
30      */
notifyInsetsControlChanged()31     default void notifyInsetsControlChanged() {
32     };
33 
34     /**
35      * @return {@link WindowState} of this target, if any.
36      */
getWindow()37     default WindowState getWindow() {
38         return null;
39     }
40 
41     /**
42      * @return The requested visibility of this target.
43      */
getImeRequestedVisibility(@nsetsState.InternalInsetsType int type)44     default boolean getImeRequestedVisibility(@InsetsState.InternalInsetsType int type) {
45         return InsetsState.getDefaultVisibility(type);
46     }
47 
48     /**
49      * @return The requested {@link InsetsState} of this target.
50      */
getRequestedInsetsState()51     default InsetsState getRequestedInsetsState() {
52         return InsetsState.EMPTY;
53     }
54 
55     /**
56      * Instructs the control target to show inset sources.
57      *
58      * @param types to specify which types of insets source window should be shown.
59      * @param fromIme {@code true} if IME show request originated from {@link InputMethodService}.
60      */
showInsets(@nsetsType int types, boolean fromIme)61     default void showInsets(@InsetsType int types, boolean fromIme) {
62     }
63 
64     /**
65      * Instructs the control target to hide inset sources.
66      *
67      * @param types to specify which types of insets source window should be hidden.
68      * @param fromIme {@code true} if IME hide request originated from {@link InputMethodService}.
69      */
hideInsets(@nsetsType int types, boolean fromIme)70     default void hideInsets(@InsetsType int types, boolean fromIme) {
71     }
72 
73     /**
74      * Returns {@code true} if the control target allows the system to show transient windows.
75      */
canShowTransient()76     default boolean canShowTransient() {
77         return false;
78     }
79 
80     /** Returns {@code target.getWindow()}, or null if {@code target} is {@code null}. */
asWindowOrNull(InsetsControlTarget target)81     static WindowState asWindowOrNull(InsetsControlTarget target) {
82         return target != null ? target.getWindow() : null;
83     }
84 }
85