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.annotation.Nullable; 20 import android.util.SparseArray; 21 import android.util.proto.ProtoOutputStream; 22 import android.view.InsetsController.AnimationType; 23 import android.view.InsetsController.LayoutInsetsDuringAnimation; 24 import android.view.WindowInsets.Type.InsetsType; 25 import android.view.inputmethod.ImeTracker; 26 27 /** 28 * Interface representing a runner for an insets animation. 29 * 30 * @hide 31 */ 32 public interface InsetsAnimationControlRunner { 33 34 /** 35 * @return The {@link InsetsType} the animation of this runner controls. 36 */ getTypes()37 @InsetsType int getTypes(); 38 39 /** 40 * @return The {@link InsetsType} the animation of this runner is controlling. This can be 41 * changed if a control is revoked. 42 */ getControllingTypes()43 @InsetsType int getControllingTypes(); 44 45 /** 46 * Notifies {@link InsetsType types} of control are getting revoked. 47 */ notifyControlRevoked(@nsetsType int types)48 void notifyControlRevoked(@InsetsType int types); 49 50 /** 51 * Updates the surface positions of the controls owned by this runner if there is any. 52 * 53 * @param controls An array of {@link InsetsSourceControl} that the caller newly receives. 54 */ updateSurfacePosition(SparseArray<InsetsSourceControl> controls)55 void updateSurfacePosition(SparseArray<InsetsSourceControl> controls); 56 57 /** 58 * Cancels the animation. 59 */ cancel()60 void cancel(); 61 62 /** 63 * @return The animation this runner is running. 64 */ getAnimation()65 WindowInsetsAnimation getAnimation(); 66 67 /** 68 * @return Whether {@link #getTypes()} contains a specific {@link InsetsType}. 69 */ controlsType(@nsetsType int type)70 default boolean controlsType(@InsetsType int type) { 71 return (getTypes() & type) != 0; 72 } 73 74 /** 75 * @return The animation type this runner is running. 76 */ getAnimationType()77 @AnimationType int getAnimationType(); 78 79 /** 80 * @return The token tracking the current IME request or {@code null} otherwise. 81 */ 82 @Nullable getStatsToken()83 ImeTracker.Token getStatsToken(); 84 85 /** 86 * Updates the desired layout insets during the animation. 87 * 88 * @param layoutInsetsDuringAnimation Whether the insets should be shown or hidden 89 */ updateLayoutInsetsDuringAnimation( @ayoutInsetsDuringAnimation int layoutInsetsDuringAnimation)90 void updateLayoutInsetsDuringAnimation( 91 @LayoutInsetsDuringAnimation int layoutInsetsDuringAnimation); 92 93 /** 94 * 95 * Export the state of classes that implement this interface into a protocol buffer 96 * output stream. 97 * 98 * @param proto Stream to write the state to 99 * @param fieldId FieldId of the implementation class 100 */ dumpDebug(ProtoOutputStream proto, long fieldId)101 void dumpDebug(ProtoOutputStream proto, long fieldId); 102 } 103