Home | History | Annotate | Download | only in stack
      1 /*
      2  * Copyright (C) 2014 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 com.android.systemui.statusbar.stack;
     18 
     19 import java.util.ArrayList;
     20 
     21 /**
     22  * Filters the animations for only a certain type of properties.
     23  */
     24 public class AnimationFilter {
     25     boolean animateAlpha;
     26     boolean animateY;
     27     boolean animateZ;
     28     boolean animateScale;
     29     boolean animateHeight;
     30     boolean animateTopInset;
     31     boolean animateDimmed;
     32     boolean animateDark;
     33     boolean animateHideSensitive;
     34     boolean hasDelays;
     35     boolean hasGoToFullShadeEvent;
     36 
     37     public AnimationFilter animateAlpha() {
     38         animateAlpha = true;
     39         return this;
     40     }
     41 
     42     public AnimationFilter animateY() {
     43         animateY = true;
     44         return this;
     45     }
     46 
     47     public AnimationFilter hasDelays() {
     48         hasDelays = true;
     49         return this;
     50     }
     51 
     52     public AnimationFilter animateZ() {
     53         animateZ = true;
     54         return this;
     55     }
     56 
     57     public AnimationFilter animateScale() {
     58         animateScale = true;
     59         return this;
     60     }
     61 
     62     public AnimationFilter animateHeight() {
     63         animateHeight = true;
     64         return this;
     65     }
     66 
     67     public AnimationFilter animateTopInset() {
     68         animateTopInset = true;
     69         return this;
     70     }
     71 
     72     public AnimationFilter animateDimmed() {
     73         animateDimmed = true;
     74         return this;
     75     }
     76 
     77     public AnimationFilter animateDark() {
     78         animateDark = true;
     79         return this;
     80     }
     81 
     82     public AnimationFilter animateHideSensitive() {
     83         animateHideSensitive = true;
     84         return this;
     85     }
     86 
     87     /**
     88      * Combines multiple filters into {@code this} filter, using or as the operand .
     89      *
     90      * @param events The animation events from the filters to combine.
     91      */
     92     public void applyCombination(ArrayList<NotificationStackScrollLayout.AnimationEvent> events) {
     93         reset();
     94         int size = events.size();
     95         for (int i = 0; i < size; i++) {
     96             combineFilter(events.get(i).filter);
     97             if (events.get(i).animationType ==
     98                     NotificationStackScrollLayout.AnimationEvent.ANIMATION_TYPE_GO_TO_FULL_SHADE) {
     99                 hasGoToFullShadeEvent = true;
    100             }
    101         }
    102     }
    103 
    104     private void combineFilter(AnimationFilter filter) {
    105         animateAlpha |= filter.animateAlpha;
    106         animateY |= filter.animateY;
    107         animateZ |= filter.animateZ;
    108         animateScale |= filter.animateScale;
    109         animateHeight |= filter.animateHeight;
    110         animateTopInset |= filter.animateTopInset;
    111         animateDimmed |= filter.animateDimmed;
    112         animateDark |= filter.animateDark;
    113         animateHideSensitive |= filter.animateHideSensitive;
    114         hasDelays |= filter.hasDelays;
    115     }
    116 
    117     private void reset() {
    118         animateAlpha = false;
    119         animateY = false;
    120         animateZ = false;
    121         animateScale = false;
    122         animateHeight = false;
    123         animateTopInset = false;
    124         animateDimmed = false;
    125         animateDark = false;
    126         animateHideSensitive = false;
    127         hasDelays = false;
    128         hasGoToFullShadeEvent = false;
    129     }
    130 }
    131