blob: 5cbf3b852018e10cadda3d782be7071e436b6629 [file] [log] [blame]
Jorim Jaggi5bb571d2018-11-06 14:42:04 +01001/*
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
19import android.annotation.NonNull;
20import android.graphics.Insets;
Tiger Huang332793b2019-10-29 23:21:27 +080021import android.view.WindowInsets.Type.InsetsType;
Jorim Jaggi98c75652019-01-10 23:49:02 +010022import android.view.WindowInsetsAnimationListener.InsetsAnimation;
Jorim Jaggi5bb571d2018-11-06 14:42:04 +010023
24/**
25 * Interface to control a window inset animation frame-by-frame.
26 * @hide pending unhide
27 */
28public interface WindowInsetsAnimationController {
29
30 /**
31 * Retrieves the {@link Insets} when the windows this animation is controlling are fully hidden.
Jorim Jaggi98c75652019-01-10 23:49:02 +010032 * <p>
33 * If there are any animation listeners registered, this value is the same as
34 * {@link InsetsAnimation#getLowerBound()} that will be passed into the callbacks.
Jorim Jaggi5bb571d2018-11-06 14:42:04 +010035 *
36 * @return Insets when the windows this animation is controlling are fully hidden.
Jorim Jaggi98c75652019-01-10 23:49:02 +010037 *
38 * @see InsetsAnimation#getLowerBound()
Jorim Jaggi5bb571d2018-11-06 14:42:04 +010039 */
40 @NonNull Insets getHiddenStateInsets();
41
42 /**
43 * Retrieves the {@link Insets} when the windows this animation is controlling are fully shown.
44 * <p>
45 * In case the size of a window causing insets is changing in the middle of the animation, we
46 * execute that height change after this animation has finished.
Jorim Jaggi98c75652019-01-10 23:49:02 +010047 * <p>
48 * If there are any animation listeners registered, this value is the same as
49 * {@link InsetsAnimation#getUpperBound()} that will be passed into the callbacks.
Jorim Jaggi5bb571d2018-11-06 14:42:04 +010050 *
51 * @return Insets when the windows this animation is controlling are fully shown.
Jorim Jaggi98c75652019-01-10 23:49:02 +010052 *
53 * @see InsetsAnimation#getUpperBound()
Jorim Jaggi5bb571d2018-11-06 14:42:04 +010054 */
55 @NonNull Insets getShownStateInsets();
56
57 /**
58 * @return The current insets on the window. These will follow any animation changes.
59 */
60 @NonNull Insets getCurrentInsets();
61
62 /**
Tiger Huang332793b2019-10-29 23:21:27 +080063 * @return The {@link InsetsType}s this object is currently controlling.
Jorim Jaggi5bb571d2018-11-06 14:42:04 +010064 */
Tiger Huang332793b2019-10-29 23:21:27 +080065 @InsetsType int getTypes();
Jorim Jaggi5bb571d2018-11-06 14:42:04 +010066
67 /**
68 * Modifies the insets by indirectly moving the windows around in the system that are causing
69 * window insets.
70 * <p>
71 * Note that this will <b>not</b> inform the view system of a full inset change via
72 * {@link View#dispatchApplyWindowInsets} in order to avoid a full layout pass during the
Jorim Jaggi98c75652019-01-10 23:49:02 +010073 * animation. If you'd like to animate views during a window inset animation, register a
74 * {@link WindowInsetsAnimationListener} by calling
75 * {@link View#setWindowInsetsAnimationListener(WindowInsetsAnimationListener)} that will be
76 * notified about any insets change via {@link WindowInsetsAnimationListener#onProgress} during
77 * the animation.
Jorim Jaggi5bb571d2018-11-06 14:42:04 +010078 * <p>
79 * {@link View#dispatchApplyWindowInsets} will instead be called once the animation has
80 * finished, i.e. once {@link #finish} has been called.
81 *
82 * @param insets The new insets to apply. Based on the requested insets, the system will
83 * calculate the positions of the windows in the system causing insets such that
84 * the resulting insets of that configuration will match the passed in parameter.
85 * Note that these insets are being clamped to the range from
86 * {@link #getHiddenStateInsets} to {@link #getShownStateInsets}
Jorim Jaggi98c75652019-01-10 23:49:02 +010087 *
88 * @see WindowInsetsAnimationListener
89 * @see View#setWindowInsetsAnimationListener(WindowInsetsAnimationListener)
Jorim Jaggi5bb571d2018-11-06 14:42:04 +010090 */
91 void changeInsets(@NonNull Insets insets);
92
93 /**
94 * @param shownTypes The list of windows causing insets that should remain shown after finishing
95 * the animation.
96 */
Tiger Huang332793b2019-10-29 23:21:27 +080097 void finish(@InsetsType int shownTypes);
Jorim Jaggi5bb571d2018-11-06 14:42:04 +010098}