blob: b70832315e2c256b9011fe2400bca62445470b44 [file] [log] [blame]
Jorim Jaggib6030952018-10-23 18:31:52 +02001/*
2 * Copyright (C) 2018 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
17package android.view;
18
Jorim Jaggi2ae39132019-01-24 13:02:50 +010019import static android.view.WindowInsets.Type.ime;
20
Jorim Jaggi5bb571d2018-11-06 14:42:04 +010021import android.annotation.NonNull;
Jorim Jaggib6030952018-10-23 18:31:52 +020022import android.view.WindowInsets.Type.InsetType;
23
24/**
25 * Interface to control windows that generate insets.
26 *
27 * TODO Needs more information and examples once the API is more baked.
28 * @hide pending unhide
29 */
30public interface WindowInsetsController {
31
32 /**
33 * Makes a set of windows that cause insets appear on screen.
34 * <p>
35 * Note that if the window currently doesn't have control over a certain type, it will apply the
36 * change as soon as the window gains control. The app can listen to the event by observing
Jorim Jaggi2ae39132019-01-24 13:02:50 +010037 * {@link View#onApplyWindowInsets} and checking visibility with {@link WindowInsets#isVisible}.
Jorim Jaggib6030952018-10-23 18:31:52 +020038 *
39 * @param types A bitmask of {@link WindowInsets.Type.InsetType} specifying what windows the app
40 * would like to make appear on screen.
Jorim Jaggi2ae39132019-01-24 13:02:50 +010041 * @hide
Jorim Jaggib6030952018-10-23 18:31:52 +020042 */
43 void show(@InsetType int types);
44
45 /**
46 * Makes a set of windows causing insets disappear.
47 * <p>
48 * Note that if the window currently doesn't have control over a certain type, it will apply the
49 * change as soon as the window gains control. The app can listen to the event by observing
Jorim Jaggi2ae39132019-01-24 13:02:50 +010050 * {@link View#onApplyWindowInsets} and checking visibility with {@link WindowInsets#isVisible}.
Jorim Jaggib6030952018-10-23 18:31:52 +020051 *
52 * @param types A bitmask of {@link WindowInsets.Type.InsetType} specifying what windows the app
53 * would like to make disappear.
Jorim Jaggi2ae39132019-01-24 13:02:50 +010054 * @hide
Jorim Jaggib6030952018-10-23 18:31:52 +020055 */
56 void hide(@InsetType int types);
Jorim Jaggi5bb571d2018-11-06 14:42:04 +010057
58 /**
59 * Lets the application control window inset animations in a frame-by-frame manner by modifying
60 * the position of the windows in the system causing insets directly.
61 *
62 * @param types The {@link InsetType}s the application has requested to control.
63 * @param listener The {@link WindowInsetsAnimationControlListener} that gets called when the
64 * windows are ready to be controlled, among other callbacks.
Jorim Jaggi2ae39132019-01-24 13:02:50 +010065 * @hide
Jorim Jaggi5bb571d2018-11-06 14:42:04 +010066 */
67 void controlWindowInsetsAnimation(@InsetType int types,
68 @NonNull WindowInsetsAnimationControlListener listener);
Jorim Jaggi2ae39132019-01-24 13:02:50 +010069
70 /**
71 * Lets the application control the animation for showing the IME in a frame-by-frame manner by
72 * modifying the position of the IME when it's causing insets.
73 *
74 * @param listener The {@link WindowInsetsAnimationControlListener} that gets called when the
75 * IME are ready to be controlled, among other callbacks.
76 */
77 default void controlInputMethodAnimation(
78 @NonNull WindowInsetsAnimationControlListener listener) {
79 controlWindowInsetsAnimation(ime(), listener);
80 }
81
82 /**
83 * Makes the IME appear on screen.
84 * <p>
85 * Note that if the window currently doesn't have control over the IME, because it doesn't have
86 * focus, it will apply the change as soon as the window gains control. The app can listen to
87 * the event by observing {@link View#onApplyWindowInsets} and checking visibility with
88 * {@link WindowInsets#isVisible}.
89 *
90 * @see #controlInputMethodAnimation(WindowInsetsAnimationControlListener)
91 * @see #hideInputMethod()
92 */
93 default void showInputMethod() {
94 show(ime());
95 }
96
97 /**
98 * Makes the IME disappear on screen.
99 * <p>
100 * Note that if the window currently doesn't have control over IME, because it doesn't have
101 * focus, it will apply the change as soon as the window gains control. The app can listen to
102 * the event by observing {@link View#onApplyWindowInsets} and checking visibility with
103 * {@link WindowInsets#isVisible}.
104 *
105 * @see #controlInputMethodAnimation(WindowInsetsAnimationControlListener)
106 * @see #showInputMethod()
107 */
108 default void hideInputMethod() {
109 hide(ime());
110 }
Jorim Jaggib6030952018-10-23 18:31:52 +0200111}