Jorim Jaggi | 5bb571d | 2018-11-06 14:42:04 +0100 | [diff] [blame] | 1 | /* |
| 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 | |
| 17 | package android.view; |
| 18 | |
| 19 | import android.annotation.NonNull; |
| 20 | import android.graphics.Insets; |
Tiger Huang | 332793b | 2019-10-29 23:21:27 +0800 | [diff] [blame] | 21 | import android.view.WindowInsets.Type.InsetsType; |
Jorim Jaggi | 98c7565 | 2019-01-10 23:49:02 +0100 | [diff] [blame] | 22 | import android.view.WindowInsetsAnimationListener.InsetsAnimation; |
Jorim Jaggi | 5bb571d | 2018-11-06 14:42:04 +0100 | [diff] [blame] | 23 | |
| 24 | /** |
| 25 | * Interface to control a window inset animation frame-by-frame. |
| 26 | * @hide pending unhide |
| 27 | */ |
| 28 | public interface WindowInsetsAnimationController { |
| 29 | |
| 30 | /** |
| 31 | * Retrieves the {@link Insets} when the windows this animation is controlling are fully hidden. |
Jorim Jaggi | 98c7565 | 2019-01-10 23:49:02 +0100 | [diff] [blame] | 32 | * <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 Jaggi | 5bb571d | 2018-11-06 14:42:04 +0100 | [diff] [blame] | 35 | * |
| 36 | * @return Insets when the windows this animation is controlling are fully hidden. |
Jorim Jaggi | 98c7565 | 2019-01-10 23:49:02 +0100 | [diff] [blame] | 37 | * |
| 38 | * @see InsetsAnimation#getLowerBound() |
Jorim Jaggi | 5bb571d | 2018-11-06 14:42:04 +0100 | [diff] [blame] | 39 | */ |
| 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 Jaggi | 98c7565 | 2019-01-10 23:49:02 +0100 | [diff] [blame] | 47 | * <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 Jaggi | 5bb571d | 2018-11-06 14:42:04 +0100 | [diff] [blame] | 50 | * |
| 51 | * @return Insets when the windows this animation is controlling are fully shown. |
Jorim Jaggi | 98c7565 | 2019-01-10 23:49:02 +0100 | [diff] [blame] | 52 | * |
| 53 | * @see InsetsAnimation#getUpperBound() |
Jorim Jaggi | 5bb571d | 2018-11-06 14:42:04 +0100 | [diff] [blame] | 54 | */ |
| 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 Huang | 332793b | 2019-10-29 23:21:27 +0800 | [diff] [blame] | 63 | * @return The {@link InsetsType}s this object is currently controlling. |
Jorim Jaggi | 5bb571d | 2018-11-06 14:42:04 +0100 | [diff] [blame] | 64 | */ |
Tiger Huang | 332793b | 2019-10-29 23:21:27 +0800 | [diff] [blame] | 65 | @InsetsType int getTypes(); |
Jorim Jaggi | 5bb571d | 2018-11-06 14:42:04 +0100 | [diff] [blame] | 66 | |
| 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 Jaggi | 98c7565 | 2019-01-10 23:49:02 +0100 | [diff] [blame] | 73 | * 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 Jaggi | 5bb571d | 2018-11-06 14:42:04 +0100 | [diff] [blame] | 78 | * <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 Jaggi | 98c7565 | 2019-01-10 23:49:02 +0100 | [diff] [blame] | 87 | * |
| 88 | * @see WindowInsetsAnimationListener |
| 89 | * @see View#setWindowInsetsAnimationListener(WindowInsetsAnimationListener) |
Jorim Jaggi | 5bb571d | 2018-11-06 14:42:04 +0100 | [diff] [blame] | 90 | */ |
| 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 Huang | 332793b | 2019-10-29 23:21:27 +0800 | [diff] [blame] | 97 | void finish(@InsetsType int shownTypes); |
Jorim Jaggi | 5bb571d | 2018-11-06 14:42:04 +0100 | [diff] [blame] | 98 | } |