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