• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 
getScrollY()47     public int getScrollY() {
48         return mScrollY;
49     }
50 
setScrollY(int scrollY)51     public void setScrollY(int scrollY) {
52         this.mScrollY = scrollY;
53     }
54 
onBeginDrag(View view)55     public void onBeginDrag(View view) {
56         mDraggedViews.add(view);
57     }
58 
onDragFinished(View view)59     public void onDragFinished(View view) {
60         mDraggedViews.remove(view);
61     }
62 
getDraggedViews()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      */
setDimmed(boolean dimmed)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 */
setDark(boolean dark)76     public void setDark(boolean dark) {
77         mDark = dark;
78     }
79 
setHideSensitive(boolean hideSensitive)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      */
setActivatedChild(ActivatableNotificationView activatedChild)88     public void setActivatedChild(ActivatableNotificationView activatedChild) {
89         mActivatedChild = activatedChild;
90     }
91 
isDimmed()92     public boolean isDimmed() {
93         return mDimmed;
94     }
95 
isDark()96     public boolean isDark() {
97         return mDark;
98     }
99 
isHideSensitive()100     public boolean isHideSensitive() {
101         return mHideSensitive;
102     }
103 
getActivatedChild()104     public ActivatableNotificationView getActivatedChild() {
105         return mActivatedChild;
106     }
107 
setOverScrollAmount(float amount, boolean onTop)108     public void setOverScrollAmount(float amount, boolean onTop) {
109         if (onTop) {
110             mOverScrollTopAmount = amount;
111         } else {
112             mOverScrollBottomAmount = amount;
113         }
114     }
115 
getOverScrollAmount(boolean top)116     public float getOverScrollAmount(boolean top) {
117         return top ? mOverScrollTopAmount : mOverScrollBottomAmount;
118     }
119 
getSpeedBumpIndex()120     public int getSpeedBumpIndex() {
121         return mSpeedBumpIndex;
122     }
123 
setSpeedBumpIndex(int speedBumpIndex)124     public void setSpeedBumpIndex(int speedBumpIndex) {
125         mSpeedBumpIndex = speedBumpIndex;
126     }
127 
setHeadsUpManager(HeadsUpManager headsUpManager)128     public void setHeadsUpManager(HeadsUpManager headsUpManager) {
129         mHeadsUpManager = headsUpManager;
130     }
131 
getStackTranslation()132     public float getStackTranslation() {
133         return mStackTranslation;
134     }
135 
setStackTranslation(float stackTranslation)136     public void setStackTranslation(float stackTranslation) {
137         mStackTranslation = stackTranslation;
138     }
139 
getLayoutHeight()140     public int getLayoutHeight() {
141         return mLayoutHeight;
142     }
143 
setLayoutHeight(int layoutHeight)144     public void setLayoutHeight(int layoutHeight) {
145         mLayoutHeight = layoutHeight;
146     }
147 
getTopPadding()148     public float getTopPadding() {
149         return mTopPadding;
150     }
151 
setTopPadding(int topPadding)152     public void setTopPadding(int topPadding) {
153         mTopPadding = topPadding;
154     }
155 
getInnerHeight()156     public int getInnerHeight() {
157         return mLayoutHeight - mTopPadding;
158     }
159 
isShadeExpanded()160     public boolean isShadeExpanded() {
161         return mShadeExpanded;
162     }
163 
setShadeExpanded(boolean shadeExpanded)164     public void setShadeExpanded(boolean shadeExpanded) {
165         mShadeExpanded = shadeExpanded;
166     }
167 
setMaxHeadsUpTranslation(float maxHeadsUpTranslation)168     public void setMaxHeadsUpTranslation(float maxHeadsUpTranslation) {
169         mMaxHeadsUpTranslation = maxHeadsUpTranslation;
170     }
171 
getMaxHeadsUpTranslation()172     public float getMaxHeadsUpTranslation() {
173         return mMaxHeadsUpTranslation;
174     }
175 
setDismissAllInProgress(boolean dismissAllInProgress)176     public void setDismissAllInProgress(boolean dismissAllInProgress) {
177         mDismissAllInProgress = dismissAllInProgress;
178     }
179 
isDismissAllInProgress()180     public boolean isDismissAllInProgress() {
181         return mDismissAllInProgress;
182     }
183 }
184