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 android.view.View;
     20 
     21 import com.android.systemui.statusbar.ActivatableNotificationView;
     22 import com.android.systemui.statusbar.ExpandableNotificationRow;
     23 import com.android.systemui.statusbar.policy.HeadsUpManager;
     24 
     25 import java.util.ArrayList;
     26 
     27 /**
     28  * A global state to track all input states for the algorithm.
     29  */
     30 public class AmbientState {
     31     private ArrayList<View> mDraggedViews = new ArrayList<View>();
     32     private int mScrollY;
     33     private boolean mDimmed;
     34     private ActivatableNotificationView mActivatedChild;
     35     private float mOverScrollTopAmount;
     36     private float mOverScrollBottomAmount;
     37     private int mSpeedBumpIndex = -1;
     38     private boolean mDark;
     39     private boolean mHideSensitive;
     40     private HeadsUpManager mHeadsUpManager;
     41     private float mStackTranslation;
     42     private int mLayoutHeight;
     43     private int mTopPadding;
     44     private boolean mShadeExpanded;
     45     private float mMaxHeadsUpTranslation;
     46     private boolean mDismissAllInProgress;
     47 
     48     public int getScrollY() {
     49         return mScrollY;
     50     }
     51 
     52     public void setScrollY(int scrollY) {
     53         this.mScrollY = scrollY;
     54     }
     55 
     56     public void onBeginDrag(View view) {
     57         mDraggedViews.add(view);
     58     }
     59 
     60     public void onDragFinished(View view) {
     61         mDraggedViews.remove(view);
     62     }
     63 
     64     public ArrayList<View> getDraggedViews() {
     65         return mDraggedViews;
     66     }
     67 
     68     /**
     69      * @param dimmed Whether we are in a dimmed state (on the lockscreen), where the backgrounds are
     70      *               translucent and everything is scaled back a bit.
     71      */
     72     public void setDimmed(boolean dimmed) {
     73         mDimmed = dimmed;
     74     }
     75 
     76     /** In dark mode, we draw as little as possible, assuming a black background */
     77     public void setDark(boolean dark) {
     78         mDark = dark;
     79     }
     80 
     81     public void setHideSensitive(boolean hideSensitive) {
     82         mHideSensitive = hideSensitive;
     83     }
     84 
     85     /**
     86      * In dimmed mode, a child can be activated, which happens on the first tap of the double-tap
     87      * interaction. This child is then scaled normally and its background is fully opaque.
     88      */
     89     public void setActivatedChild(ActivatableNotificationView activatedChild) {
     90         mActivatedChild = activatedChild;
     91     }
     92 
     93     public boolean isDimmed() {
     94         return mDimmed;
     95     }
     96 
     97     public boolean isDark() {
     98         return mDark;
     99     }
    100 
    101     public boolean isHideSensitive() {
    102         return mHideSensitive;
    103     }
    104 
    105     public ActivatableNotificationView getActivatedChild() {
    106         return mActivatedChild;
    107     }
    108 
    109     public void setOverScrollAmount(float amount, boolean onTop) {
    110         if (onTop) {
    111             mOverScrollTopAmount = amount;
    112         } else {
    113             mOverScrollBottomAmount = amount;
    114         }
    115     }
    116 
    117     public float getOverScrollAmount(boolean top) {
    118         return top ? mOverScrollTopAmount : mOverScrollBottomAmount;
    119     }
    120 
    121     public int getSpeedBumpIndex() {
    122         return mSpeedBumpIndex;
    123     }
    124 
    125     public void setSpeedBumpIndex(int speedBumpIndex) {
    126         mSpeedBumpIndex = speedBumpIndex;
    127     }
    128 
    129     public void setHeadsUpManager(HeadsUpManager headsUpManager) {
    130         mHeadsUpManager = headsUpManager;
    131     }
    132 
    133     public float getStackTranslation() {
    134         return mStackTranslation;
    135     }
    136 
    137     public void setStackTranslation(float stackTranslation) {
    138         mStackTranslation = stackTranslation;
    139     }
    140 
    141     public int getLayoutHeight() {
    142         return mLayoutHeight;
    143     }
    144 
    145     public void setLayoutHeight(int layoutHeight) {
    146         mLayoutHeight = layoutHeight;
    147     }
    148 
    149     public float getTopPadding() {
    150         return mTopPadding;
    151     }
    152 
    153     public void setTopPadding(int topPadding) {
    154         mTopPadding = topPadding;
    155     }
    156 
    157     public int getInnerHeight() {
    158         return mLayoutHeight - mTopPadding - getTopHeadsUpPushIn();
    159     }
    160 
    161     private int getTopHeadsUpPushIn() {
    162         ExpandableNotificationRow topHeadsUpEntry = getTopHeadsUpEntry();
    163         return topHeadsUpEntry != null ? topHeadsUpEntry.getHeadsUpHeight()
    164                 - topHeadsUpEntry.getMinHeight(): 0;
    165     }
    166 
    167     public boolean isShadeExpanded() {
    168         return mShadeExpanded;
    169     }
    170 
    171     public void setShadeExpanded(boolean shadeExpanded) {
    172         mShadeExpanded = shadeExpanded;
    173     }
    174 
    175     public void setMaxHeadsUpTranslation(float maxHeadsUpTranslation) {
    176         mMaxHeadsUpTranslation = maxHeadsUpTranslation;
    177     }
    178 
    179     public float getMaxHeadsUpTranslation() {
    180         return mMaxHeadsUpTranslation;
    181     }
    182 
    183     public ExpandableNotificationRow getTopHeadsUpEntry() {
    184         HeadsUpManager.HeadsUpEntry topEntry = mHeadsUpManager.getTopEntry();
    185         return topEntry == null ? null : topEntry.entry.row;
    186     }
    187 
    188     public void setDismissAllInProgress(boolean dismissAllInProgress) {
    189         mDismissAllInProgress = dismissAllInProgress;
    190     }
    191 
    192     public boolean isDismissAllInProgress() {
    193         return mDismissAllInProgress;
    194     }
    195 }
    196