blob: 4a7ea965b2200938340ecb58e1e7d55ca320d06d [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;
26
27/**
28 * A global state to track all input states for the algorithm.
29 */
30public class AmbientState {
31 private ArrayList<View> mDraggedViews = new ArrayList<View>();
32 private int mScrollY;
33 private boolean mDimmed;
Selim Cineka32ab602014-06-11 15:06:01 +020034 private ActivatableNotificationView mActivatedChild;
Selim Cinek8d9ff9c2014-05-12 15:13:04 +020035 private float mOverScrollTopAmount;
36 private float mOverScrollBottomAmount;
Selim Cinekc27437b2014-05-14 10:23:33 +020037 private int mSpeedBumpIndex = -1;
John Spurlockbf370992014-06-17 13:58:31 -040038 private boolean mDark;
Jorim Jaggiae441282014-08-01 02:45:18 +020039 private boolean mHideSensitive;
Selim Cinekb8f09cf2015-03-16 17:09:28 -070040 private HeadsUpManager mHeadsUpManager;
Selim Cineka59ecc32015-04-07 10:51:49 -070041 private float mStackTranslation;
Selim Cinekb8f09cf2015-03-16 17:09:28 -070042 private int mLayoutHeight;
43 private int mTopPadding;
44 private boolean mShadeExpanded;
45 private float mMaxHeadsUpTranslation;
Jorim Jaggid552d9d2014-05-07 19:41:13 +020046
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
John Spurlockbf370992014-06-17 13:58:31 -040075 /** In dark mode, we draw as little as possible, assuming a black background */
76 public void setDark(boolean dark) {
77 mDark = dark;
78 }
79
Jorim Jaggiae441282014-08-01 02:45:18 +020080 public void setHideSensitive(boolean hideSensitive) {
81 mHideSensitive = hideSensitive;
82 }
83
Jorim Jaggid552d9d2014-05-07 19:41:13 +020084 /**
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 */
Selim Cineka32ab602014-06-11 15:06:01 +020088 public void setActivatedChild(ActivatableNotificationView activatedChild) {
Jorim Jaggid552d9d2014-05-07 19:41:13 +020089 mActivatedChild = activatedChild;
90 }
91
92 public boolean isDimmed() {
93 return mDimmed;
94 }
95
John Spurlockbf370992014-06-17 13:58:31 -040096 public boolean isDark() {
97 return mDark;
98 }
99
Jorim Jaggiae441282014-08-01 02:45:18 +0200100 public boolean isHideSensitive() {
101 return mHideSensitive;
102 }
103
Selim Cineka32ab602014-06-11 15:06:01 +0200104 public ActivatableNotificationView getActivatedChild() {
Jorim Jaggid552d9d2014-05-07 19:41:13 +0200105 return mActivatedChild;
106 }
Selim Cinek8d9ff9c2014-05-12 15:13:04 +0200107
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 }
Selim Cinekc27437b2014-05-14 10:23:33 +0200119
120 public int getSpeedBumpIndex() {
121 return mSpeedBumpIndex;
122 }
123
124 public void setSpeedBumpIndex(int speedBumpIndex) {
125 mSpeedBumpIndex = speedBumpIndex;
126 }
Selim Cinekb8f09cf2015-03-16 17:09:28 -0700127
128 public void setHeadsUpManager(HeadsUpManager headsUpManager) {
129 mHeadsUpManager = headsUpManager;
130 }
131
Selim Cineka59ecc32015-04-07 10:51:49 -0700132 public float getStackTranslation() {
133 return mStackTranslation;
Selim Cinekb8f09cf2015-03-16 17:09:28 -0700134 }
135
Selim Cineka59ecc32015-04-07 10:51:49 -0700136 public void setStackTranslation(float stackTranslation) {
137 mStackTranslation = stackTranslation;
Selim Cinekb8f09cf2015-03-16 17:09:28 -0700138 }
139
140 public int getLayoutHeight() {
141 return mLayoutHeight;
142 }
143
144 public void setLayoutHeight(int layoutHeight) {
145 mLayoutHeight = layoutHeight;
146 }
147
Selim Cineka59ecc32015-04-07 10:51:49 -0700148 public float getTopPadding() {
Selim Cinekb8f09cf2015-03-16 17:09:28 -0700149 return mTopPadding;
150 }
151
152 public void setTopPadding(int topPadding) {
153 mTopPadding = topPadding;
154 }
155
156 public int getInnerHeight() {
Selim Cineka59ecc32015-04-07 10:51:49 -0700157 return mLayoutHeight - mTopPadding - getTopHeadsUpPushIn();
158 }
159
160 private int getTopHeadsUpPushIn() {
161 ExpandableNotificationRow topHeadsUpEntry = getTopHeadsUpEntry();
162 return topHeadsUpEntry != null ? topHeadsUpEntry.getHeadsUpHeight()
163 - topHeadsUpEntry.getMinHeight(): 0;
Selim Cinekb8f09cf2015-03-16 17:09:28 -0700164 }
165
166 public boolean isShadeExpanded() {
167 return mShadeExpanded;
168 }
169
170 public void setShadeExpanded(boolean shadeExpanded) {
171 mShadeExpanded = shadeExpanded;
172 }
173
174 public void setMaxHeadsUpTranslation(float maxHeadsUpTranslation) {
175 mMaxHeadsUpTranslation = maxHeadsUpTranslation;
176 }
177
178 public float getMaxHeadsUpTranslation() {
179 return mMaxHeadsUpTranslation;
180 }
Selim Cineka59ecc32015-04-07 10:51:49 -0700181
182 public ExpandableNotificationRow getTopHeadsUpEntry() {
183 HeadsUpManager.HeadsUpEntry topEntry = mHeadsUpManager.getTopEntry();
184 return topEntry == null ? null : topEntry.entry.row;
185 }
Jorim Jaggid552d9d2014-05-07 19:41:13 +0200186}