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 animateHeight;
     29     boolean animateTopInset;
     30     boolean animateDimmed;
     31     boolean animateDark;
     32     boolean animateHideSensitive;
     33     public boolean animateShadowAlpha;
     34     boolean hasDelays;
     35     boolean hasGoToFullShadeEvent;
     36     boolean hasDarkEvent;
     37     boolean hasHeadsUpDisappearClickEvent;
     38     int darkAnimationOriginIndex;
     39 
     40     public AnimationFilter animateAlpha() {
     41         animateAlpha = true;
     42         return this;
     43     }
     44 
     45     public AnimationFilter animateY() {
     46         animateY = true;
     47         return this;
     48     }
     49 
     50     public AnimationFilter hasDelays() {
     51         hasDelays = true;
     52         return this;
     53     }
     54 
     55     public AnimationFilter animateZ() {
     56         animateZ = true;
     57         return this;
     58     }
     59 
     60     public AnimationFilter animateHeight() {
     61         animateHeight = true;
     62         return this;
     63     }
     64 
     65     public AnimationFilter animateTopInset() {
     66         animateTopInset = true;
     67         return this;
     68     }
     69 
     70     public AnimationFilter animateDimmed() {
     71         animateDimmed = true;
     72         return this;
     73     }
     74 
     75     public AnimationFilter animateDark() {
     76         animateDark = true;
     77         return this;
     78     }
     79 
     80     public AnimationFilter animateHideSensitive() {
     81         animateHideSensitive = true;
     82         return this;
     83     }
     84 
     85     public AnimationFilter animateShadowAlpha() {
     86         animateShadowAlpha = true;
     87         return this;
     88     }
     89 
     90     /**
     91      * Combines multiple filters into {@code this} filter, using or as the operand .
     92      *
     93      * @param events The animation events from the filters to combine.
     94      */
     95     public void applyCombination(ArrayList<NotificationStackScrollLayout.AnimationEvent> events) {
     96         reset();
     97         int size = events.size();
     98         for (int i = 0; i < size; i++) {
     99             NotificationStackScrollLayout.AnimationEvent ev = events.get(i);
    100             combineFilter(events.get(i).filter);
    101             if (ev.animationType ==
    102                     NotificationStackScrollLayout.AnimationEvent.ANIMATION_TYPE_GO_TO_FULL_SHADE) {
    103                 hasGoToFullShadeEvent = true;
    104             }
    105             if (ev.animationType ==
    106                     NotificationStackScrollLayout.AnimationEvent.ANIMATION_TYPE_DARK) {
    107                 hasDarkEvent = true;
    108                 darkAnimationOriginIndex = ev.darkAnimationOriginIndex;
    109             }
    110             if (ev.animationType == NotificationStackScrollLayout.AnimationEvent
    111                     .ANIMATION_TYPE_HEADS_UP_DISAPPEAR_CLICK) {
    112                 hasHeadsUpDisappearClickEvent = true;
    113             }
    114         }
    115     }
    116 
    117     private void combineFilter(AnimationFilter filter) {
    118         animateAlpha |= filter.animateAlpha;
    119         animateY |= filter.animateY;
    120         animateZ |= filter.animateZ;
    121         animateHeight |= filter.animateHeight;
    122         animateTopInset |= filter.animateTopInset;
    123         animateDimmed |= filter.animateDimmed;
    124         animateDark |= filter.animateDark;
    125         animateHideSensitive |= filter.animateHideSensitive;
    126         animateShadowAlpha |= filter.animateShadowAlpha;
    127         hasDelays |= filter.hasDelays;
    128     }
    129 
    130     private void reset() {
    131         animateAlpha = false;
    132         animateY = false;
    133         animateZ = false;
    134         animateHeight = false;
    135         animateShadowAlpha = false;
    136         animateTopInset = false;
    137         animateDimmed = false;
    138         animateDark = false;
    139         animateHideSensitive = false;
    140         hasDelays = false;
    141         hasGoToFullShadeEvent = false;
    142         hasDarkEvent = false;
    143         hasHeadsUpDisappearClickEvent = false;
    144         darkAnimationOriginIndex =
    145                 NotificationStackScrollLayout.AnimationEvent.DARK_ANIMATION_ORIGIN_INDEX_ABOVE;
    146     }
    147 }
    148