| 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 android.view; |
| 18 | |
| 19 | import android.util.SparseArray; |
| 20 | import android.util.proto.ProtoOutputStream; |
| 21 | import android.view.InsetsController.AnimationType; |
| 22 | import android.view.InsetsState.InternalInsetsType; |
| 23 | import android.view.WindowInsets.Type.InsetsType; |
| 24 | |
| 25 | /** |
| 26 | * Interface representing a runner for an insets animation. |
| 27 | * |
| 28 | * @hide |
| 29 | */ |
| 30 | public interface InsetsAnimationControlRunner { |
| 31 | |
| 32 | /** |
| 33 | * @return The {@link InsetsType} the animation of this runner controls. |
| 34 | */ |
| 35 | @InsetsType int getTypes(); |
| 36 | |
| 37 | /** |
| 38 | * @return The {@link InsetsType} the animation of this runner is controlling. This can be |
| 39 | * changed if a control is revoked. |
| 40 | */ |
| 41 | @InsetsType int getControllingTypes(); |
| 42 | |
| 43 | /** |
| 44 | * Notifies {@link InsetsType types} of control are getting revoked. |
| 45 | */ |
| 46 | void notifyControlRevoked(@InsetsType int types); |
| 47 | |
| 48 | /** |
| 49 | * Updates the surface positions of the controls owned by this runner if there is any. |
| 50 | * |
| 51 | * @param controls An array of {@link InsetsSourceControl} that the caller newly receives. |
| 52 | */ |
| 53 | void updateSurfacePosition(SparseArray<InsetsSourceControl> controls); |
| 54 | |
| 55 | /** |
| 56 | * Cancels the animation. |
| 57 | */ |
| 58 | void cancel(); |
| 59 | |
| 60 | /** |
| 61 | * @return The animation this runner is running. |
| 62 | */ |
| 63 | WindowInsetsAnimation getAnimation(); |
| 64 | |
| 65 | /** |
| 66 | * @return Whether {@link #getTypes()} maps to a specific {@link InternalInsetsType}. |
| 67 | */ |
| 68 | default boolean controlsInternalType(@InternalInsetsType int type) { |
| 69 | return InsetsState.toInternalType(getTypes()).contains(type); |
| 70 | } |
| 71 | |
| 72 | /** |
| 73 | * @return The animation type this runner is running. |
| 74 | */ |
| 75 | @AnimationType int getAnimationType(); |
| 76 | |
| 77 | /** |
| 78 | * |
| 79 | * Export the state of classes that implement this interface into a protocol buffer |
| 80 | * output stream. |
| 81 | * |
| 82 | * @param proto Stream to write the state to |
| 83 | * @param fieldId FieldId of the implementation class |
| 84 | */ |
| 85 | void dumpDebug(ProtoOutputStream proto, long fieldId); |
| 86 | } |