blob: f2b971f4c6fd60434369664afa08d35d2118cad8 [file] [log] [blame]
Jorim Jaggid552d9d2014-05-07 19:41:13 +02001/*
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
17package com.android.systemui.statusbar.stack;
18
19import android.view.View;
Selim Cineka59ecc32015-04-07 10:51:49 -070020
Selim Cineka32ab602014-06-11 15:06:01 +020021import com.android.systemui.statusbar.ActivatableNotificationView;
Selim Cineka59ecc32015-04-07 10:51:49 -070022import com.android.systemui.statusbar.ExpandableNotificationRow;
Selim Cinekb8f09cf2015-03-16 17:09:28 -070023import com.android.systemui.statusbar.policy.HeadsUpManager;
Jorim Jaggid552d9d2014-05-07 19:41:13 +020024
25import java.util.ArrayList;
Selim Cineka59ecc32015-04-07 10:51:49 -070026import java.util.TreeSet;
Jorim Jaggid552d9d2014-05-07 19:41:13 +020027
28/**
29 * A global state to track all input states for the algorithm.
30 */
31public class AmbientState {
32 private ArrayList<View> mDraggedViews = new ArrayList<View>();
33 private int mScrollY;
34 private boolean mDimmed;
Selim Cineka32ab602014-06-11 15:06:01 +020035 private ActivatableNotificationView mActivatedChild;
Selim Cinek8d9ff9c2014-05-12 15:13:04 +020036 private float mOverScrollTopAmount;
37 private float mOverScrollBottomAmount;
Selim Cinekc27437b2014-05-14 10:23:33 +020038 private int mSpeedBumpIndex = -1;
John Spurlockbf370992014-06-17 13:58:31 -040039 private boolean mDark;
Jorim Jaggiae441282014-08-01 02:45:18 +020040 private boolean mHideSensitive;
Selim Cinekb8f09cf2015-03-16 17:09:28 -070041 private HeadsUpManager mHeadsUpManager;
Selim Cineka59ecc32015-04-07 10:51:49 -070042 private float mStackTranslation;
Selim Cinekb8f09cf2015-03-16 17:09:28 -070043 private int mLayoutHeight;
44 private int mTopPadding;
45 private boolean mShadeExpanded;
46 private float mMaxHeadsUpTranslation;
Jorim Jaggid552d9d2014-05-07 19:41:13 +020047
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
John Spurlockbf370992014-06-17 13:58:31 -040076 /** In dark mode, we draw as little as possible, assuming a black background */
77 public void setDark(boolean dark) {
78 mDark = dark;
79 }
80
Jorim Jaggiae441282014-08-01 02:45:18 +020081 public void setHideSensitive(boolean hideSensitive) {
82 mHideSensitive = hideSensitive;
83 }
84
Jorim Jaggid552d9d2014-05-07 19:41:13 +020085 /**
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 */
Selim Cineka32ab602014-06-11 15:06:01 +020089 public void setActivatedChild(ActivatableNotificationView activatedChild) {
Jorim Jaggid552d9d2014-05-07 19:41:13 +020090 mActivatedChild = activatedChild;
91 }
92
93 public boolean isDimmed() {
94 return mDimmed;
95 }
96
John Spurlockbf370992014-06-17 13:58:31 -040097 public boolean isDark() {
98 return mDark;
99 }
100
Jorim Jaggiae441282014-08-01 02:45:18 +0200101 public boolean isHideSensitive() {
102 return mHideSensitive;
103 }
104
Selim Cineka32ab602014-06-11 15:06:01 +0200105 public ActivatableNotificationView getActivatedChild() {
Jorim Jaggid552d9d2014-05-07 19:41:13 +0200106 return mActivatedChild;
107 }
Selim Cinek8d9ff9c2014-05-12 15:13:04 +0200108
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 }
Selim Cinekc27437b2014-05-14 10:23:33 +0200120
121 public int getSpeedBumpIndex() {
122 return mSpeedBumpIndex;
123 }
124
125 public void setSpeedBumpIndex(int speedBumpIndex) {
126 mSpeedBumpIndex = speedBumpIndex;
127 }
Selim Cinekb8f09cf2015-03-16 17:09:28 -0700128
129 public void setHeadsUpManager(HeadsUpManager headsUpManager) {
130 mHeadsUpManager = headsUpManager;
131 }
132
Selim Cineka59ecc32015-04-07 10:51:49 -0700133 public TreeSet<HeadsUpManager.HeadsUpEntry> getSortedHeadsUpEntries() {
134 return mHeadsUpManager.getSortedEntries();
Selim Cinekb8f09cf2015-03-16 17:09:28 -0700135 }
136
Selim Cineka59ecc32015-04-07 10:51:49 -0700137 public float getStackTranslation() {
138 return mStackTranslation;
Selim Cinekb8f09cf2015-03-16 17:09:28 -0700139 }
140
Selim Cineka59ecc32015-04-07 10:51:49 -0700141 public void setStackTranslation(float stackTranslation) {
142 mStackTranslation = stackTranslation;
Selim Cinekb8f09cf2015-03-16 17:09:28 -0700143 }
144
145 public int getLayoutHeight() {
146 return mLayoutHeight;
147 }
148
149 public void setLayoutHeight(int layoutHeight) {
150 mLayoutHeight = layoutHeight;
151 }
152
Selim Cineka59ecc32015-04-07 10:51:49 -0700153 public float getTopPadding() {
Selim Cinekb8f09cf2015-03-16 17:09:28 -0700154 return mTopPadding;
155 }
156
157 public void setTopPadding(int topPadding) {
158 mTopPadding = topPadding;
159 }
160
161 public int getInnerHeight() {
Selim Cineka59ecc32015-04-07 10:51:49 -0700162 return mLayoutHeight - mTopPadding - getTopHeadsUpPushIn();
163 }
164
165 private int getTopHeadsUpPushIn() {
166 ExpandableNotificationRow topHeadsUpEntry = getTopHeadsUpEntry();
167 return topHeadsUpEntry != null ? topHeadsUpEntry.getHeadsUpHeight()
168 - topHeadsUpEntry.getMinHeight(): 0;
Selim Cinekb8f09cf2015-03-16 17:09:28 -0700169 }
170
171 public boolean isShadeExpanded() {
172 return mShadeExpanded;
173 }
174
175 public void setShadeExpanded(boolean shadeExpanded) {
176 mShadeExpanded = shadeExpanded;
177 }
178
179 public void setMaxHeadsUpTranslation(float maxHeadsUpTranslation) {
180 mMaxHeadsUpTranslation = maxHeadsUpTranslation;
181 }
182
183 public float getMaxHeadsUpTranslation() {
184 return mMaxHeadsUpTranslation;
185 }
Selim Cineka59ecc32015-04-07 10:51:49 -0700186
187 public ExpandableNotificationRow getTopHeadsUpEntry() {
188 HeadsUpManager.HeadsUpEntry topEntry = mHeadsUpManager.getTopEntry();
189 return topEntry == null ? null : topEntry.entry.row;
190 }
Jorim Jaggid552d9d2014-05-07 19:41:13 +0200191}