Home | History | Annotate | Download | only in view
      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;
     21 import android.view.WindowInsets.Type.InsetType;
     22 import android.view.WindowInsetsAnimationListener.InsetsAnimation;
     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.
     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.
     35      *
     36      * @return Insets when the windows this animation is controlling are fully hidden.
     37      *
     38      * @see InsetsAnimation#getLowerBound()
     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.
     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.
     50      *
     51      * @return Insets when the windows this animation is controlling are fully shown.
     52      *
     53      * @see InsetsAnimation#getUpperBound()
     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     /**
     63      * @return The {@link InsetType}s this object is currently controlling.
     64      */
     65     @InsetType int getTypes();
     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
     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.
     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}
     87      *
     88      * @see WindowInsetsAnimationListener
     89      * @see View#setWindowInsetsAnimationListener(WindowInsetsAnimationListener)
     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      */
     97     void finish(@InsetType int shownTypes);
     98 }
     99