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